# Use of response token/code when using social login connection

**URL:** <https://community.auth0.com/t/use-of-response-token-code-when-using-social-login-connection/9201>\
**Category:** Get Help\
**Tags:** api, token, social-connections\
**Created:** [January 15, 2018, 6:48pm UTC](https://community.auth0.com/t/use-of-response-token-code-when-using-social-login-connection/9201 "2018-01-15T18:48:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![priya.sharma.9362](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/priya.sharma.9362/32/14302_2.png) [@priya.sharma.9362](https://community.auth0.com/u/priya.sharma.9362)\
**Post date:** [January 15, 2018, 6:48pm UTC](https://community.auth0.com/t/use-of-response-token-code-when-using-social-login-connection/9201/1 "2018-01-15T18:48:55Z")

</div>

When using the URL to enable social login, I am getting a token/ code as a response (depending on the choice while preparing the URL).  
The user is getting created successfully at Auth0 and the redirectUrl is called.  
But I am dubious about how to use the received token/code. As our API requires Auth0 access\_token for validating the user and granting access.

---

<div class="post-metadata">

**Author:** ![Anny](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/anny/32/13140_2.png) [@Anny](https://community.auth0.com/u/Anny)\
**Post date:** [January 15, 2018, 9:55pm UTC](https://community.auth0.com/t/use-of-response-token-code-when-using-social-login-connection/9201/2 "2018-01-15T21:55:53Z")

</div>

If you got back a `code`, you need to exchange the code for an `access_token` and an `id_token` (if you need it) by calling the [oauth/token](https://auth0.com/docs/api/authentication#authorization-code) endpoint. If you used `response_type=token`, then you receive an `access_token` directly and you don’t need to make any other call to Auth0.

The `access_token` that you get back needs to have the audience ( `aud` ) of your API, which you set by configuring the API identifier in the Dashboard as explained [here](https://auth0.com/docs/apis#how-to-configure-an-api-in-auth0). You set the audience by adding it as a query string parameter when calling the `/authorize` endpoint as explained in [this tutorial](https://auth0.com/docs/api-auth/tutorials/implicit-grant) if you’re building an SPA (implicit grant flow, `response_type=token` or `response_type=token id_token`) or [this one](https://auth0.com/docs/api-auth/tutorials/authorization-code-grant) if you’re building a web application (authorization code grant flow, `response_type=code`).

Once you have an `access_token` with the right `audience` and scope (if you’re using them in your API to grant more specific permissions), you need to validate it in your API. [This document](https://auth0.com/docs/api-auth/tutorials/verify-access-token) explains how to validate tokens in more detail. We also have a set of [Quickstarts](https://auth0.com/docs/quickstart/backend) that explain how to validate them in different programming languages.

You can inspect the JWT tokens you get through [jwt.io](https://jwt.io) in case you need to troubleshoot them (to verify that the right audience is being set, for example).

Please take into consideration that when you’re creating an API in the Dashboard you can set the signing algorithm to be either RS256 or HS256. It’s highly recommended that you use RS256 for your use case and this is the approach that our Quickstarts explain.

---

<div class="post-metadata">

**Author:** ![priya.sharma.9362](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/priya.sharma.9362/32/14302_2.png) [@priya.sharma.9362](https://community.auth0.com/u/priya.sharma.9362)\
**Post date:** [January 16, 2018, 1:17pm UTC](https://community.auth0.com/t/use-of-response-token-code-when-using-social-login-connection/9201/3 "2018-01-16T13:17:49Z")

</div>

Okay, I got it. I was receiving an id\_token which is a string since I didn’t pass the audience value.

Thanks a lot for the help @anny!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [July 25, 2019, 9:38am UTC](https://community.auth0.com/t/use-of-response-token-code-when-using-social-login-connection/9201/4 "2019-07-25T09:38:31Z")

</div>


