Invalid access token from ios login

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

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:

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:

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

1 Like