Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

Google OAuth in React Native doesn't logout

$
0
0

I'm setting up the Google OAuth using Expo's expo-google-app-auth and I have no problem with the login process, but I'm having difficulty logging out.

    import * as Google from 'expo-google-app-auth'

    const [accessToken, setAccessToken] = useState('')
    const storeToken = async (token) => {
        try {
            await AsyncStorage.setItem(token, GOOGLE_TOKEN)
        } catch (err) {
            throw new Error(err)
        }
    }

    const signInWithGoogleAsync = async () => {
        try {
            const result = await Google.logInAsync({
                iosClientId: IOS_CLIENT_ID,
                scopes: ['profile', 'email'],
            });

            if (result.type === 'success') {
                storeToken(result.accessToken)
                setAccessToken(results.accessToken)
            } else {
                return { cancelled: true };
            }
        } catch (e) {
            return { error: true };
        }
    }

    const signoutWithGoogleAsync = async () => {
        try {
            console.log("token in delete", accessToken)
            await Google.logOutAsync({ accessToken, iosClientId: IOS_CLIENT_ID })
        } catch (err) {
            throw new Error(err)
        }
    }

Following is how I login and logout:

<TouchableHighlight onPress={() => signInWithGoogleAsync()}>
            <Text>Login with Google</Text>
        </TouchableHighlight>
        <TouchableHighlight onPress={() => signoutWithGoogleAsync()}>
            <Text>Logout</Text>
        </TouchableHighlight>

However, when I logout, there are no errors, but doesn't log out of the Google's account. When I click on login button again, the login process doesn't require inputting the password.


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>