# Invalid access token from ios login

**URL:** <https://community.auth0.com/t/invalid-access-token-from-ios-login/84714>\
**Category:** Get Help\
**Created:** [June 7, 2022, 10:02am UTC](https://community.auth0.com/t/invalid-access-token-from-ios-login/84714 "2022-06-07T10:02:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thinkmorestupidless](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thinkmorestupidless/32/25317_2.png) [@thinkmorestupidless](https://community.auth0.com/u/thinkmorestupidless)\
**Post date:** [June 7, 2022, 10:02am UTC](https://community.auth0.com/t/invalid-access-token-from-ios-login/84714/1 "2022-06-07T10:02:48Z")

</div>

iOS/Swift SDK

I’ve configured everything and am able to login on simulator and device (very smooth!)

However, the access token provided in the login response is not a valid JWT - it only contains 2 sections, the middle section is blank, there’s just two dots together.

`blahblahblah..blahblahblah`

Clearly i’m missing something obvious here but i’m not sure what it is - as i say, everything seems to be working correctly (the id token can be validated and the info correctly read from it) so i’m assuming i’m not configuring something in the Auth0 application for the iOS application? I haven’t changed anything from the defaults there as i’m not sure there’s anything that i can change that would solve this problem.

T

---

<div class="post-metadata">

**Author:** ![thinkmorestupidless](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thinkmorestupidless/32/25317_2.png) [@thinkmorestupidless](https://community.auth0.com/u/thinkmorestupidless)\
**Post date:** [June 7, 2022, 11:30am UTC](https://community.auth0.com/t/invalid-access-token-from-ios-login/84714/2 "2022-06-07T11:30:20Z")

</div>

Found it… problem was i hadn’t provided the ‘audience’ to the call. In case anyone else hits this problem here’s what i had to do:

The documentation says do this:

```auto
Auth0
            .webAuth()
            .start { result in
                switch result {
                case .success(let credentials):
                    self.loggedIn = true
                case .failure(let error):
                    print("Failed with: \(error)")
                }
            }

```

This will return a mangled access token - if you add the call to provide the audience:

```auto
Auth0
            .webAuth()
            .audience("https://the.identifier.for.your.api.in.your.apis.dashboard")
            .start { result in
                switch result {
                case .success(let credentials):
                    self.loggedIn = true
                case .failure(let error):
                    print("Failed with: \(error)")
                }
            }

```

Then you’ll get a valid access token with all the stuff you need in the payload.

T

---

<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:** [November 20, 2024, 9:30pm UTC](https://community.auth0.com/t/invalid-access-token-from-ios-login/84714/3 "2024-11-20T21:30:35Z")

</div>

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