# Account linking with Google action sdk, how to get idToken

**URL:** <https://community.auth0.com/t/account-linking-with-google-action-sdk-how-to-get-idtoken/8293>\
**Category:** Get Help\
**Tags:** user-linking\
**Created:** [September 25, 2017, 9:43pm UTC](https://community.auth0.com/t/account-linking-with-google-action-sdk-how-to-get-idtoken/8293 "2017-09-25T21:43:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jens](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jens](https://community.auth0.com/u/jens)\
**Post date:** [September 25, 2017, 9:43pm UTC](https://community.auth0.com/t/account-linking-with-google-action-sdk-how-to-get-idtoken/8293/1 "2017-09-25T21:43:57Z")

</div>

Account linking with Google action sdk, how to get idToken

Hi,  
I’m trying to use Auth0 for authentication for Google account linking in a google action sdk app.  
[Google actions account-linking](https://developers.google.com/actions/identity/account-linking)  
In my Auth0 rule file, I set a context variable

```
context.accessToken'https://at.mydomain.xyz'] = user.app_metadata.myvar;
context.idToken"https://at.mydomain.xyz"] = user.app_metadata.myvar;

```

On the Google Action side I was expecting to be able to get the ‘myvar’ from the request/Bearer:

```
var myvar = (jwt.decode(req.headers.authorization.replace("Bearer ", "")))"https://at.mydomain.xyz"];

```

However I only get short Bearer () which is not valid jwt.  
What am I doing wrong here?  
Thanks in advance!

### Example

```
  headers: 
   { 'content-type': 'application/json;charset=UTF-8',
     'google-assistant-api-version': 'v1',
     authorization: 'Bearer 1kypWQBJYGmVwK9P',

```

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [September 26, 2017, 7:59pm UTC](https://community.auth0.com/t/account-linking-with-google-action-sdk-how-to-get-idtoken/8293/2 "2017-09-26T19:59:31Z")

</div>

I’m not at all familiar with Google Actions SDK, however I can explain the likely cause for the access token you receive from Auth0 to be an opaque access token and not a JWT.

ID tokens will always be JWT’s because the spec mandates it, however, access token can use any format acceptable by the API to which they are meant to be sent to as an authorization mechanism. Currently, Auth0 can issue access tokens that will be suitable to call:

- only Auth0 provided API’s, in particular, the `/userinfo` endpoint; **in this case the access token format is an implementation detail subject to change, but at this time it’s an opaque access token**.
- only your own defined API’s (aka the custom API’s you create in the APIs section); **in this case the access token format currently being used is the JWT one; again, new format can be supported in the future, but you would likely be able to choose which one to use.**
- both your own defined API and also the Auth0 provided `/userinfo` API; in this case the token will also currently be a JWT that has multiple audiences. Have in mind that this will only apply under specific circumstances like the API using RS256 and the request including the `openid` scope.

**If you perform only a user authentication request according to OpenID Connect you’ll get an opaque access token suitable for `/userinfo`**. If you want an access token suitable to your own defined API then you need to include the `audience` parameter during the authentication/authorization request. Including the audience will currently mean a JWT access token will be issued and as such the construct `context.accessToken'https://example.com'] = user.app_metadata.value;` will indeed add a claim to the generated JWT access token.

Finally, an restating my initial introduction, this explain why the opaque access token can be issued, but my lack of knowledge of Google Actions does not allow me to say that addressing this will indeed meet your requirement for you Google Actions use case.

---

<div class="post-metadata">

**Author:** ![jens](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jens](https://community.auth0.com/u/jens)\
**Post date:** [September 27, 2017, 4:11pm UTC](https://community.auth0.com/t/account-linking-with-google-action-sdk-how-to-get-idtoken/8293/3 "2017-09-27T16:11:01Z")

</div>

Thank you for the explanation jmangelo! The account linking with GA works after applying your proposed changes.

---

<div class="post-metadata">

**Author:** ![jens](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jens](https://community.auth0.com/u/jens)\
**Post date:** [September 27, 2017, 4:11pm UTC](https://community.auth0.com/t/account-linking-with-google-action-sdk-how-to-get-idtoken/8293/4 "2017-09-27T16:11:01Z")

</div>

Thank you for the explanation jmangelo! The account linking with GA works after applying your proposed changes.

---

<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:** [March 2, 2018, 5:56am UTC](https://community.auth0.com/t/account-linking-with-google-action-sdk-how-to-get-idtoken/8293/5 "2018-03-02T05:56:40Z")

</div>


