Ran on ios in expo go. Authorization token works correctly but then cannot redeem. Gives me the error below, I looked but the solution to this error is an to put an origin header, which isn't possible in ios.
More info: AADSTS9002327: Tokens issued for the 'Single-Page Application' client-type may only beredeemed via cross-origin requests.
const discovery = AuthSession.useAutoDiscovery('https://login.microsoftonline.com/' + tenantId +'/v2.0');
const redirectUri = AuthSession.makeRedirectUri({scheme: "{my scheme}", path: 'auth'});
// Request
const [request, result, promptAsync] = AuthSession.useAuthRequest(
{
clientId,
scopes: ["User.Read"],
redirectUri,
prompt: AuthSession.Prompt.SelectAccount
},
discovery,
);
async function getAuthToken() {
promptAsync().then(async (codeResponse) => {
if (request && codeResponse?.type === 'success' && discovery) {
AuthSession.exchangeCodeAsync(
{
clientId,
code: codeResponse.params.code,
extraParams: request.codeVerifier
? { code_verifier: request.codeVerifier }
:undefined,
redirectUri,
scopes: request.scopes
},
discovery,
).then((response) => {
//Success
}).catch(e => {console.log(e)});
}
});
}
I have tried getting the token like in the repo https://github.com/pinecat/azure-ad-graph-expo