# How to get idToken using just accessToken?

**URL:** <https://community.auth0.com/t/how-to-get-idtoken-using-just-accesstoken/7187>\
**Category:** Get Help\
**Tags:** idtoken, id\_token, access-token\
**Created:** [June 22, 2017, 12:09am UTC](https://community.auth0.com/t/how-to-get-idtoken-using-just-accesstoken/7187 "2017-06-22T00:09:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![info10](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/info10/32/7759_2.png) [@info10](https://community.auth0.com/u/info10)\
**Post date:** [June 22, 2017, 12:09am UTC](https://community.auth0.com/t/how-to-get-idtoken-using-just-accesstoken/7187/1 "2017-06-22T00:09:13Z")

</div>

If all I have is the user’s accessToken, I know I can call auth0lock getUserInfo() and get their details

But how can I get their id\_token with just an accessToken?

---

<div class="post-metadata">

**Author:** ![jaiwant.mulik](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jaiwant.mulik](https://community.auth0.com/u/jaiwant.mulik)\
**Post date:** [June 22, 2017, 1:05am UTC](https://community.auth0.com/t/how-to-get-idtoken-using-just-accesstoken/7187/2 "2017-06-22T01:05:32Z")

</div>

This is PHP … Code below get the `sub` claim for user that generated the access token. Not exactly what you are looking for but you might use it as starting point. Using the JWTVerifier, as:

```
  use Auth0\SDK\Exception\CoreException;
  use Auth0\SDK\Exception\InvalidTokenException;
    use Auth0\SDK\Exception\ApiException;
    use Auth0\SDK\JWTVerifier;
    use Auth0\SDK\Helpers\Cache\FileSystemCacheHandler;
    
    // Create the verifier
    try {
      $verifier = new JWTVerifier(
          'valid_audiences' => $apiConfig'Auth0']'valid_audiences'],
          'authorized_iss' => $apiConfig'Auth0']'authorized_iss'],
          'supported_algs' => $apiConfig'Auth0']'supported_algs'],
      ]);
    } catch(CoreException $e) {
           // error
    	exit;
    }
    
    // Verify token the access token.
    try {
      $decoded = $verifier->verifyAndDecode($token);
    } catch(CoreException $e) {
      header("HTTP/1.1 401 Unauthorized");
    	echo "401 Unauthorized - 6B2C6263-9EC6-48F7-B9B6-7E978B2EC5DE - " . $e->getMessage();
    	exit;
    } catch(InvalidTokenException $e) {
      header("HTTP/1.1 401 Unauthorized");
    	echo "401 Unauthorized - 1D543A6A-C6A5-4940-9C3F-066CD5755735 ";
      echo json_encode($headers);
    	exit;
    }
    
    // Check if we got a sub clam in JWT.
    if(!isset($decoded->sub)) {
      header("HTTP/1.1 401 Unauthorized");
    	echo "401 Unauthorized - C6AA49C7-5985-4191-A58B-CF0A2CF29D08 - sub empty or not defined";
      echo json_encode($headers); 
      exit;
    } else {
      $AuthSub = $decoded->sub;
    }

```

The “sub” claim in $decoded has the `user_id`. It has been a bit since I looked at it but the `$decoded` object **might** object have identity information or the token embedded. Hope this helps.

---

<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:54am UTC](https://community.auth0.com/t/how-to-get-idtoken-using-just-accesstoken/7187/3 "2018-03-02T05:54:50Z")

</div>


