Token refreshing in Swift

Hello, I’m trying to update my request with the credential.authorize() function used here:

I’m using it like this, and when I print out my request headers, it shows an Authorization header with a token. For some reason, this token is not accepted by our API:

func prepareGETRequest(_ urlString: String) async -> URLRequest {
    let url = URL(string: urlString)
    var request = URLRequest(url: url!)
    if let credential = Credential.default {
        await credential.authorize(&request)
    }
    return request
}

When I manually attach our access token, it works, but it would be nice to make use of the convenience function to refresh our token automatically. Why might this refreshed token not be accepted by our API?

Did you confirm that the refreshed token being sent to your API is valid, based on whatever you are doing to validate tokens, whether that’s local validation (checking the payload and signing key) or remote (sending it to the /introspect endpoint)?

1 Like

I’ll check on this with our backend team