# Access\_token in JWT format - iOS SDK

**URL:** <https://community.auth0.com/t/access-token-in-jwt-format-ios-sdk/7583>\
**Category:** Get Help\
**Tags:** access\_token, jwt, ios\
**Created:** [July 19, 2017, 7:37pm UTC](https://community.auth0.com/t/access-token-in-jwt-format-ios-sdk/7583 "2017-07-19T19:37:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamesscott](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jamesscott](https://community.auth0.com/u/jamesscott)\
**Post date:** [July 19, 2017, 7:37pm UTC](https://community.auth0.com/t/access-token-in-jwt-format-ios-sdk/7583/1 "2017-07-19T19:37:20Z")

</div>

Hi,  
I am using this function for getting access\_token, but still I don’t get it in JWT format.

```
enum Auth0Key:String{
    case SCOPE = "openid user offline_access update:current_user_identities"
    case CONNECTION = "Username-Password-Authentication"
}

Auth0
.authentication()
.login(usernameOrEmail: username, password: password, connection: Auth0Key.CONNECTION.rawValue, scope: Auth0Key.SCOPE.rawValue, parameters: "device":"test", "audience":Environment.shared.baseUrl])
.start { result in
    switch result {}

```

I post in payload audience, but I don’t get still access\_token in JWT. Could you help me, to set it?  
Thanks.  
Vladimir

---

<div class="post-metadata">

**Author:** ![Ryan\_Chenkie](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ryan_chenkie/32/5854_2.png) [@Ryan\_Chenkie](https://community.auth0.com/u/Ryan_Chenkie)\
**Post date:** [July 19, 2017, 9:41pm UTC](https://community.auth0.com/t/access-token-in-jwt-format-ios-sdk/7583/2 "2017-07-19T21:41:01Z")

</div>

Hi Vladimir,  
What have you set as your `audience`? To get a JWT access token your `audience` needs to be the identifier for an API you create in the [Auth0 dashboard](https://manage.auth0.com/#/apis).

---

<div class="post-metadata">

**Author:** ![jamesscott](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jamesscott](https://community.auth0.com/u/jamesscott)\
**Post date:** [July 19, 2017, 9:48pm UTC](https://community.auth0.com/t/access-token-in-jwt-format-ios-sdk/7583/3 "2017-07-19T21:48:44Z")

</div>

Thanks for reaction. I am using identifier from Auth0 dashboard, but still no luck. I forgot to mention, that I am using it on tvOS, but it should work there too. Should I post in payload something else?

---

<div class="post-metadata">

**Author:** ![yuichi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yuichi/32/7861_2.png) [@yuichi](https://community.auth0.com/u/yuichi)\
**Post date:** [August 8, 2017, 3:13pm UTC](https://community.auth0.com/t/access-token-in-jwt-format-ios-sdk/7583/4 "2017-08-08T15:13:24Z")

</div>

I am seeing a very similar situation. I just downloaded sample from official repo ([GitHub - auth0-samples/auth0-ios-swift-sample: Auth0 Integration Samples for iOS Swift](https://github.com/auth0-samples/auth0-ios-swift-sample/)) and ran with updated Auth0.plist.

So, the code snippet is something like this

```
Auth0
        .webAuth()
        .audience("https://" + clientInfo.domain + "/userinfo")
        .scope("openid profile")
        .start {
            switch $0 {
            case .failure(let error):
               // Handle the error
               print("Error: \(error)")
            case .success(let credentials):
               guard let accessToken = credentials.accessToken, let idToken = credentials.idToken else { return } ...

```

It works fine and lets me login, but the `accessToken` is not JWT. Something like `KBSxkmG-OcpA6-cg`.

Please help. I cannot send this to my API server for verification.

P.S. I thought the issue is related, so I posted in this thread to consolidate. But if it is better to create my own thread, let me know.

---

<div class="post-metadata">

**Author:** ![yuichi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yuichi/32/7861_2.png) [@yuichi](https://community.auth0.com/u/yuichi)\
**Post date:** [August 8, 2017, 11:36pm UTC](https://community.auth0.com/t/access-token-in-jwt-format-ios-sdk/7583/5 "2017-08-08T23:36:59Z")

</div>

Self answering my quesiton. Ryan’s comment above had the answer in it.

I had to replace

```
"https://" + clientInfo.domain + "/userinfo" 

```

to something like

```
TestAPI

```

(API name I have created in the portal), and voila. Access token returns in JWT.

In the initial example, audience is “userinfo” which requires (!?) opaque access token, and that’s why I don’t get JWT token.

---

<div class="post-metadata">

**Author:** ![lcheng\_nj](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@lcheng\_nj](https://community.auth0.com/u/lcheng_nj)\
**Post date:** [September 19, 2017, 12:39pm UTC](https://community.auth0.com/t/access-token-in-jwt-format-ios-sdk/7583/6 "2017-09-19T12:39:05Z")

</div>

How was the API “TestAPI” created?

---

<div class="post-metadata">

**Author:** ![yuichi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yuichi/32/7861_2.png) [@yuichi](https://community.auth0.com/u/yuichi)\
**Post date:** [September 19, 2017, 11:30pm UTC](https://community.auth0.com/t/access-token-in-jwt-format-ios-sdk/7583/7 "2017-09-19T23:30:34Z")

</div>

Something like this @lcheng_nj ![alt text][1]

---

<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:55am UTC](https://community.auth0.com/t/access-token-in-jwt-format-ios-sdk/7583/8 "2018-03-02T05:55:29Z")

</div>


