Hi @Young, Charles , thanks for reaching us.
I Understand you are trying to authenticate users using OAuth2.0 in a cross-platform React Native (expo) app by using Entra ID's app registration feature. You have configured the app registration as a 'Mobile and Desktop App' using the URI [http://localhost:8081/auth]. you can get an authorization code, but you cannot exchange it for an access token.
Authorization code flow is a protocol that enables a client application to obtain authorized access to protected resources like web APIs. The auth code flow requires a user-agent that supports redirection from the authorization server back to your application, PKCE adds an additional layer of security to the authorization code flow by requiring the client to generate a code challenge and a code verifier which aims to prevent interception attacks on public clients as they do not have a secret which means they do not have a real way of authenticating themselves.
You have configured the app registration as a 'Mobile and Desktop App' platform for this PKCE is not required it is recommended. Other hand PKCE is required for Single-Page-Application (SPA)
Yes, you are using SPA flow code, but you didn't mention PKCE parameters in your code: code_verifier & code_challengemethod. These two parameters are required when you set usePKCE as true.
For your reference: https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
As you mention you are not trying to make SPA, could you confirm why you are not making SPA?
If you want to authenticate for a public client like a mobile/cross-platform app PKCE is recommended as they have less security.