0

I'm using react-native-app-auth to get access token from azure ad b2c but I'm facing issues in android and in IOS in android it's showing error that Unable to complete authorization as there is no interactive call in progress. This can be due to closing the app while the authorization was in process.

https://i.stack.imgur.com/R2Fft.png

and in IOS it's redirecting but not returning anything.

that's my code

const config = {
  issuer:
    'https://ksg1806.b2clogin.com/tenantId/v2.0/',
  clientId: 'clientId',
  redirectUrl:
    Platform.OS == 'ios'
      ? 'msauth.com.gfk.consumervoice://auth'
      : 'msauth://com.gfkconsumer/Cb7s2L1nogp57%2BKdddohtF8%2Funk%3D',
  additionalParameters: {},
  scopes: ['openid'],
  serviceConfiguration: {
    authorizationEndpoint:
      'https://ksg1806.b2clogin.com/ksg1806.onmicrosoft.com/b2c_1_signup_signin/oauth2/v2.0/authorize',
    tokenEndpoint:
      'https://gfkms.b2clogin.com/GFKMS.onmicrosoft.com/b2c_1_signup_signin/oauth2/v2.0/token',
    revocationEndpoint:
      'https://gfkms.b2clogin.com/GFKMS.onmicrosoft.com/b2c_1_signup_signin/oauth2/v2.0/logout',
  },
};

  const getAccessToken = async () => {
    try {
      const authState = await authorize(config);
      console.log(authState);
    } catch (error: any) {
      Alert.alert('Failed to log in', error.message);
    }
  };

if anyone know about that please help I'm stuck here for many days

Kanwarjeet Singh
  • 144
  • 1
  • 12

1 Answers1

0

Please check if below points can narrow down the issue:

  1. For v2 endpoint scope acts as resource . If the resource identifier is omitted in the scope parameter, the resource is assumed to be Microsoft Graph. If token is for Microsoft graph try by changing or adding scope : User.Read . For example, scope=User.Read is equivalent to https://graph.microsoft.com/User.Read and offline_access is for refresh tokens Or try to Add the scope to existing openid scope like scopes: []

For example: scopes: ['openid', 'profile', email,'offline_access'], (or) scopes: ['openid', 'profile','offline_access']

Optional:Try also by giving client_secret inside the config

  1. Make sure you have set the redirect url correctly.Add a trailing slash to redirect url to your config - e.g. msauth.BUNDLEID://auth/ - failure to add that may cause it to fail in IOS.

  2. The cause may also be due to the user cancelling the operation in the middle of the process before authentication is completed.See Troubleshooting B2C | Microsoft Docs

References:

  1. AppAuth iOS Token Exchange Problems Azure AD - Stack Overflow
  2. Microsoft identity platform scopes, permissions, & consent | Microsoft Docs
  3. react-native-app-auth (github.com)
kavyaS
  • 8,026
  • 1
  • 7
  • 19