Is there a clean way to exchange the authorization code for an access token in a mobile SPA context when receiving a 400 Bad Request?
Background
Implementing Authorization Code flow with PKCE for an iOS app wrapping the Genesys Cloud Web Messaging SDK. Using code_challenge_method=S256.
Issue
The initial redirect to /oauth/authorize works. However, the subsequent POST to /oauth/token fails.
Error: POST /oauth/token returned 400 Bad Request
Response: {“error”:“invalid_grant”,“error_description”:“Authorization code has expired or been used”}
Troubleshooting
- Verified
code_verifiermatches the hashedcode_challenge. - Confirmed
redirect_urimatches exactly. - Code is exchanged immediately after redirect.
- Tried adding
grant_type=authorization_codeexplicitly.