auth0 / react-native-lock

[DEPRECATED] A wrapper of Lock to use with React Native (iOS & Android)
MIT License
277 stars 77 forks source link

Get request google Api for userinfo via accessToken! #181

Open mortezahaidari opened 4 years ago

mortezahaidari commented 4 years ago

I am currently using Expo app auth, "https://docs.expo.io/versions/latest/sdk/app-auth/" for authentication of my app. New to this React Native world, but i would like to request for userinfo from google Api which this method is using. I tried using postman, and it returns the values i would need. How can i use access token to get request for userinfo from Google Api?

The link below returned every value i needed, with bearer token of course. 'https://www.googleapis.com/oauth2/v2/userinfo'

Here is the code:

import React, { useEffect, useState } from 'react'; import { AsyncStorage, Button, StyleSheet, Text, View } from 'react-native'; import * as AppAuth from 'expo-app-auth';

export default function App() { let [authState, setAuthState] = useState(null);

useEffect(() => { (async () => { let cachedAuth = await getCachedAuthAsync(); if (cachedAuth && !authState) { setAuthState(cachedAuth); } })(); }, []);

return (

Expo AppAuth Example