We are in the process of creating a mobile application in Flutter framework. We are custom building the UI for the login and was able to successfully get the session token through Authentication Api. When tried to exchange session token for an access token through okta-oidc-ios package getting " unableToGetAuthCode" error.
Here is the code
let config = try OktaOidcConfig(with: [
"issuer": issuer,
"clientId": clientID,
"redirectUri": redirectUrl,
"scopes": "openid profile offline_access",
])
let oidcClient = try OktaOidc(configuration: config)
oidcClient.authenticate(withSessionToken: sessionToken) { stateManager, error in
print(stateManager)
if let error = error {
// Error
print(error)
return
}
// stateManager.accessToken
// stateManager.idToken
// stateManager.refreshToken
}
Here is the request url formed in the package
https://<subdomain>.okta.com/oauth2/v1/authorize?nonce=bmIB3AQg6DhzkcvbjM0sch1ddQxdv5CKE3HcQojfa34&sessionToken=20111jV5xQTTP7bkQUOmlAIYO8sQuRisKz40gHQ5w_vngW5BDtXwH-E&response_type=code&code_challenge_method=S256&scope=openid%20profile%20offline_access&code_challenge=NbMDK3COKpuzr14wgSR151ZkZ3qcZHYLTzzVZHxuVno&redirect_uri=com.okta.<subdomain>:/callback&client_id=<client_id>&state=q-dCDOiykHEpU4c1YIiVAcZF5zTSc6N5u9E6-ubX4Ik>
The response for the above request is
<OIDAuthorizationResponse: 0x600000277430, authorizationCode: (null), state: "(null)", accessToken: "(null)", accessTokenExpirationDate: (null), tokenType: (null), idToken: "(null)", scope: "(null)", additionalParameters: {
fromURI = "/oauth2/v1/authorize/redirect?okta_key=IApapd70M4IMwFeyjIBBSjQy1lwr0q15hPK1aQ506RA";
}, request: <OIDAuthorizationRequest: 0x600000a62d80, request: https://<subdomain>.okta.com/oauth2/v1/authorize?nonce=bmIB3AQg6DhzkcvbjM0sch1ddQxdv5CKE3HcQojfa34&sessionToken=20111jV5xQTTP7bkQUOmlAIYO8sQuRisKz40gHQ5w_vngW5BDtXwH-E&response_type=code&code_challenge_method=S256&scope=openid%20profile%20offline_access&code_challenge=NbMDK3COKpuzr14wgSR151ZkZ3qcZHYLTzzVZHxuVno&redirect_uri=com.okta.<subdomain>:/callback&client_id==<client_id>&state=q-dCDOiykHEpU4c1YIiVAcZF5zTSc6N5u9E6-ubX4Ik>>
I just started with okta, I might have made some mistakes in configuration on the developer console. It would be great if someone can point me to the possible reasons for this error.
thanks