Hi,
We are trying to utilize Okta to authenticate users (not company emloyees using internal systems, but end-users) of a mobile app written with React Native. After a successful signin, the app shall obtain an access token to be able to access our backend services, which will in turn verify the token using Okta JWT Verifier for Node.js. To allow the signin from our app, we try to use @okta/okta-react-native.
Now we are able to obtain access-, id- and refresh-tokens in our app, but our backend is unable to verify the access tokens sent from our App, giving error Code: “Error while resolving signing key for kid {kid}”.
Having seen the recommendations given in a similar post on this forum, we are unsure wether this error is a result of misconfiguration on our side, or we need an “api access management license” for our use case, which we assume shouldnt be the case when Okta is promoting “1000 monthly active users for free” ( https://developer.okta.com/pricing/ ).
Steps we have taken so far:
1) we have signed up for a developer account, signed into our organizations admin panel at https://dev-{ID}-admin.okta.com
2) created a client-application of type mobile/native, allowed grant types “authorization code” and “refresh token” for this client and ticked the recommended “proof key for code exchange” (PKCE) as client authentication mechanism over using a client secret.
3) created an additional authorization Server within the API/Authorization Servers Tab, thinking that it was required to use a “custom authorization server” instead of the default one in order to verify the issued tokens in our own backend.
4) Installed okta-react-native to our codebase and created an oktaAuthClient using a configuration as follows:
clientId: “{Client Id of our mobile application}”,
redirectUri: “com.{ourAppName}:/callback”,
endSessionRedirectUri: “com.{ourAppName}:/endSession”,
discoveryUri:
“https://dev-{Our Accounts Org. ID}.okta.com/oauth2/{Our Custom Auth Servers ID}/.well-known/openid-configuration”,
scopes: [“openid”, “profile”, “offline_access”],
requireHardwareBackedKeyStore: false // Since testing on a virtual device.
5) Installed OktaJWTVerifier for Node.js in our Nest.JS based Backend, Registering it as a middleware to protect our routes and calling jwtVerifier.Verify() with the following configuration:
{ issuer: ‘https://dev-{Our Okta Org ID}.okta.com/oauth2/{Our Custom Auth Server ID}’,
clientId: ‘{Client ID of our mobile application}’,
scopes: ‘[“openid”, “profile”, “offline_access”]’,
assertClaims: { aud: ‘{Client ID of our mobile Application}’ } }
6) Called https://dev-{Our Org. ID}.okta.com/oauth2/{Our Custom Auth Server ID}/v1/keys , seeing that the key-id (“kid”) it replies is not matching the kid in the access_tokens were sending from the mobile application.
Any heads-up on where we went down the wrong path would be greatly appreciated.
Kind regards,
