Request not being completed with Expo authSession

I'm quite new to app development and have ran into an error while trying to set up Google authentication, but it appears the request hasn't finished loading.

(Error message is: [Unhandled promise rejection: Error: Cannot prompt to authenticate until the request has finished loading.])

I'm not sure how I can work around this issue, perhaps some more experienced developers answer my question?

import React, { useState, useEffect } from 'react';
import { View, Text, Button, StyleSheet, TextInput } from 'react-native';
import { useAuthRequest } from 'expo-auth-session';
import * as WebBrowser from 'expo-web-browser';

WebBrowser.maybeCompleteAuthSession();

const App = () => {
    const [accessToken, setAccessToken] = useState();
    const [request, response, promptAsync] = useAuthRequest({
        iosClientId: "701989901250-95eku3luaf6qj1q0ba82dmeun3v4f486.apps.googleusercontent.com",
        expoClientId: "701989901250-ieiupvqri2hskpacksaoe7r6vjmu3e24.apps.googleusercontent.com",
        //androidClientId: "",
    });

    useEffect(() => {
        if (response?.type === "success") {
          setAccessToken(response.authentication.accessToken);
        }
      }, [response]);

    return (
        <View>
            <Button styles={styles.button} title="Sign-in with Google" /* google login button */
            onPress={() => { promptAsync({useProxy: false, showInRecents: true}) }}/>
        </View>
    );
}

EDIT: For those interested I did find a fix for this error, it was a weird issue, but all I changed was the third line and the tenth line.

// third
import * as Google from 'expo-auth-session/providers/google';
// tenth
const [request, response, promptAsync] = Google.useAuthRequest({


Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation