Google login stopped working after expo update

Google login is not working properly ever since I updated my expo from 25.0.0 to 26.0.0

try {
      const result = await Expo.Google.logInAsync({
        behavior: 'web',
        scopes: ['profile', 'email'],
        androidClientId: ANDROID_CLIENT_ID, // expo
        androidStandaloneAppClientId: 'ANDROID_STANDALONE_APP_CLIENT_ID', // apk
        iosClientId: 'IOS_CLIENT_ID',
        webClientId: 'WEB_CLIENT_ID',
      });

      if (result.type === 'success') {
        console.log("GOOGLE LOGIN SUCCESSFUL!");
        let userInfoResponse = await fetch('https://www.googleapis.com/userinfo/v2/me', {
          headers: { Authorization: `Bearer ${result.accessToken}` },
        });
        console.log('Google user info: ' + JSON.stringify(userInfoResponse));

The response printed on the last log is like this -

Google user info: {"type":"default","status":200,"ok":true,"headers":{"map":{"content-type":["application/json; charset=UTF-8"],"content-encoding":["gzip"],"x-xss-protection":["1; mode=block"],"content-length":["244"],"x-frame-options":["SAMEORIGIN"],"vary":["Origin, X-Origin, Referer"],"pragma":["no-cache"],"x-content-type-options":["nosniff"],"expires":["Mon, 01 Jan 1990 00:00:00 GMT"],"server":["ESF"],"cache-control":["no-cache, no-store, max-age=0, must-revalidate"],"alt-svc":["quic=\":443\"; ma=2592000; v=\"44,43,39,35\""],"date":["Tue, 15 Jan 2019 10:57:59 GMT"]}},"url":"https://www.googleapis.com/userinfo/v2/me","_bodyInit":{"_data":{"size":364,"blobId":"F8E573A2-B6B4-4BFF-8873-A9DD84B88908","type":"application/json","offset":0,"name":"me"}},"_bodyBlob":{"_data":{"size":364,"blobId":"F8E573A2-B6B4-4BFF-8873-A9DD84B88908","type":"application/json","offset":0,"name":"me"}}}
1 Like

Found the fix.

Turns out that google returns user info as part of the result field. It can be accessed with result.user.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.