# Exchange Google "idToken" or "authCode" for Auth0 credentials

**URL:** <https://community.auth0.com/t/exchange-google-idtoken-or-authcode-for-auth0-credentials/57623>\
**Category:** Get Help\
**Tags:** credentials, google-signup, authentication-api, social-connections\
**Created:** [February 9, 2021, 8:29pm UTC](https://community.auth0.com/t/exchange-google-idtoken-or-authcode-for-auth0-credentials/57623 "2021-02-09T20:29:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thsaraiva](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thsaraiva/32/27461_2.png) [@thsaraiva](https://community.auth0.com/u/thsaraiva)\
**Post date:** [February 9, 2021, 8:29pm UTC](https://community.auth0.com/t/exchange-google-idtoken-or-authcode-for-auth0-credentials/57623/1 "2021-02-09T20:29:51Z")

</div>

Hi,

I’m struggling to find out how to obtain Auth0 credentials, after having successfully authenticated my user with Google in my Android App following Google Sign In instructions ([การผสานรวม Google Sign-In กับแอป Android &nbsp;|&nbsp; Authentication &nbsp;|&nbsp; Google Developers](https://developers.google.com/identity/sign-in/android/sign-in)).

I have basically tried 2 approaches:

1. Obtained an `idToken` from Google like this:

Then in `onActivityResult()` I obtain the google account with the `idToken`.

1. Or, obtained an `serverAuthCode` from Google like this:  
val googleSignInOptions = Builder(GoogleSignInOptions.DEFAULT\_SIGN\_IN)  
.requestScopes(Scope(Scopes.EMAIL), Scope(Scopes.PROFILE))  
.requestServerAuthCode(BuildConfig.OATH2\_CLIENT\_ID)  
.requestEmail()  
.build()  
val googleSignInClient = GoogleSignIn.getClient(activity, googleSignInOptions)  
activity.startActivityForResult(googleSignInClient.signInIntent, 2468)

Then in `onActivityResult()` I obtain the google account with the `serverAuthCode`.

Then this is the point where I’m lost. How do I use either the `idToken` or the `serverAuthCode` to exchange it for Auth0 credentials ?

Thanks a lot !

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [February 11, 2021, 6:56pm UTC](https://community.auth0.com/t/exchange-google-idtoken-or-authcode-for-auth0-credentials/57623/3 "2021-02-11T18:56:11Z")

</div>

Hi @thsaraiva,

I’m not too familiar with setting up Google Sign-In via Google itself and not through an Auth0 SDK.

Have you checked out the docs for the Android SDK? [Auth0.Android](https://auth0.com/docs/libraries/auth0-android)

When you use Auth0, you can [outsource the authentication process](https://auth0.com/docs/microsites/add-login/add-login-native-mobile-app) and display social connections such as Google, or other types of login options in one place.

The Auth0 SDK will make the Access Token and ID Token available to your app. That way no matter how a user logs in/signs up for your app, your app only needs to integrate with Auth0 for authentication.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [June 25, 2021, 12:48pm UTC](https://community.auth0.com/t/exchange-google-idtoken-or-authcode-for-auth0-credentials/57623/4 "2021-06-25T12:48:22Z")

</div>

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