# Get Auth0 user\_id for IOS

**URL:** <https://community.auth0.com/t/get-auth0-user-id-for-ios/60399>\
**Category:** Get Help\
**Tags:** ios, auth0\
**Created:** [April 1, 2021, 1:59am UTC](https://community.auth0.com/t/get-auth0-user-id-for-ios/60399 "2021-04-01T01:59:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![elizabeth.wright](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/elizabeth.wright/32/28516_2.png) [@elizabeth.wright](https://community.auth0.com/u/elizabeth.wright)\
**Post date:** [April 1, 2021, 1:59am UTC](https://community.auth0.com/t/get-auth0-user-id-for-ios/60399/1 "2021-04-01T01:59:58Z")

</div>

I’m trying to retrieve the Auth0 userid for my app. I see that it is held in the Idtoken field but this needs to be requested during authentication. How do I do this?  
This is my current authentication request  
Auth0  
.webAuth()  
.scope(“openid offline\_access profile email”)  
.audience(“[https://xxxxxxxxxxxxx](https://xxxxxxxxxxxxx)”)  
.start { result in  
switch result {  
case .failure(let error):  
// Handle the error  
print(“Error: (error)”)  
case .success(let credentials):  
etc.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 1, 2021, 3:53pm UTC](https://community.auth0.com/t/get-auth0-user-id-for-ios/60399/3 "2021-04-01T15:53:55Z")

</div>

Hi @elizabeth.wright,

Welcome to the Community!

You should be able to see it as the `sub` claim in the token. Is that claim not being returned?

---

<div class="post-metadata">

**Author:** ![elizabeth.wright](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/elizabeth.wright/32/28516_2.png) [@elizabeth.wright](https://community.auth0.com/u/elizabeth.wright)\
**Post date:** [April 6, 2021, 7:03am UTC](https://community.auth0.com/t/get-auth0-user-id-for-ios/60399/4 "2021-04-06T07:03:49Z")

</div>

Hi Dan,

thanks for the reply. Forgive me, I must be missing something obvious. This is my login :

Auth0  
.webAuth()  
.scope(“openid offline\_access profile email”)  
.audience(“[https://xxxxxxxxx.auth0.com/userinfo](https://xxxxxxxxx.auth0.com/userinfo)”)  
.start { result in  
switch result {  
case .failure(let error):  
// Handle the error  
print(“Error: (error)”)  
case .success(let credentials):  
// make the login button a pale grey colour  
print(“Credentials: (credentials)”)

etc.

I get the access token from the credentials, but there’s no sub claim attached? If I try typing credentials.accessToken, there’s no ‘sub’ field available

```
                print("accesstoken = " , credentials.accessToken ?? "")

```

Liz

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 6, 2021, 4:24pm UTC](https://community.auth0.com/t/get-auth0-user-id-for-ios/60399/5 "2021-04-06T16:24:11Z")

</div>

Are you not recieving the ID token? Or does the ID token not contain the userID?

---

<div class="post-metadata">

**Author:** ![elizabeth.wright](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/elizabeth.wright/32/28516_2.png) [@elizabeth.wright](https://community.auth0.com/u/elizabeth.wright)\
**Post date:** [April 7, 2021, 11:39pm UTC](https://community.auth0.com/t/get-auth0-user-id-for-ios/60399/6 "2021-04-07T23:39:34Z")

</div>

Thanks Dan, I was missing the jwt decode. I have it now. Thanks for the guidance.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 8, 2021, 2:42pm UTC](https://community.auth0.com/t/get-auth0-user-id-for-ios/60399/7 "2021-04-08T14:42:44Z")

</div>

Thanks for the follow up.

---

<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:** [April 23, 2021, 2:43pm UTC](https://community.auth0.com/t/get-auth0-user-id-for-ios/60399/8 "2021-04-23T14:43:01Z")

</div>

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