question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

idToken undefined in result.authentication (authSession with Google)

See original GitHub issue

Summary

When getting a response back from promptAsync using AuthSession with Google, I get an authentication value with an undefined id_token. I know I can get the id_token by itself but I’m looking for both an access token and id_token in the same response because I can’t think of an elegant workaround to get both separately using this library (each would have to prompt the user with a popup, and worse you would have to trigger popups by asking the user to click two buttons or disable pop up blocker)

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

Web

SDK Version (managed workflow only)

40

Environment

Expo CLI 4.2.1 environment info: System: OS: Linux 5.4 Ubuntu 20.04.2 LTS (Focal Fossa) Shell: 5.0.17 - /bin/bash Binaries: Node: 12.18.1 - ~/.nvm/versions/node/v12.18.1/bin/node Yarn: 1.22.5 - /usr/local/bin/yarn npm: 6.14.5 - ~/.nvm/versions/node/v12.18.1/bin/npm Watchman: 4.9.0 - /usr/bin/watchman npmPackages: expo: ~40.0.0 => 40.0.1 react: 16.13.1 => 16.13.1 react-dom: * => 17.0.2 react-native: https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz => 0.63.2 react-native-web: ~0.13.12 => 0.13.18 react-navigation: latest => 4.4.4 npmGlobalPackages: expo-cli: 4.2.1 Expo Workflow: managed

Reproducible demo or steps to reproduce from a blank project

Just using the same code as in the docs – but not doing it on snack (since you can’t even enter your credentials there with google sign in). Other people have also seen this bug, see these links: https://stackoverflow.com/questions/66966772/expo-auth-session-providers-google-google-useauthrequest and https://forums.expo.io/t/expo-auth-session-google-useauthrequest-returns-googles-idtoken-value-as-undefined/49510

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:12
  • Comments:27

github_iconTop GitHub Comments

20reactions
fermmmcommented, May 5, 2021

Same here: There seems to be a bug in the expo-auth-session/providers/google v 3.2.3 package that returns idToken as undefined when calling Google.useAuthRequest. I’m testing on Expo Go, everything configured correctly as documentation says, web proxy credentials, everything. The only solution that worked for me to get idToken is this code provided by howard:

   const [request, response, promptAsync] = Google.useAuthRequest({
      responseType: "id_token",
      androidClientId: process.env.GOOGLE_CLIENT_ID_ANDROID,
      expoClientId: process.env.GOOGLE_CLIENT_WEB_EXPO,
      scopes: ["email"]
   });

This code is a workaround to get idToken (in the “params” key) and no other data.

The old package expo-google-app-auth seems to be returning idToken correctly along with other data.

Edit: I’ve found Google.useIdTokenAuthRequest that can be used instead of Google.useAuthRequest but seems to do the same thing than the code above. Maybe by design in the package it’s not possible to get idToken and other information at the same time. Also this Google.useIdTokenAuthRequest hook is undocumented except when you click on the firebase tab in the code example of this page

7reactions
charlestbellcommented, Feb 24, 2022

Same issue here. Using Google.useAuthRequest and the idToken on the response object is undefind.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AuthSession - Expo Documentation
Disables PKCE for implicit and id-token based auth responses. On web, the popup is presented with the dimensions that are optimized for the...
Read more >
When I do Google authentication on Android, the idToken ...
Try to use webClientId instead of clientId in initAsync It worked for me. await GoogleSignIn.initAsync({ webClientId: String(Config.
Read more >
Google Sign-In JavaScript client reference | Authentication
Use GoogleUser.getHostedDomain() on the client, and the hd claim in the ID Token on the server to verify the domain is what you...
Read more >
Expo Auth Session - Login with Google in React Native Apps ...
Hi everyone!Today I am going to show you how to authenticate with Google in your expo Android and iOS applications to receive an...
Read more >
React Native Google Login - Medium
Installation: expo install expo-auth-session expo-random ... }const creds = GoogleAuthProvider.credential(result!.params.id_token);
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found