Azure-Samples / active-directory-b2c-ios-swift-native-msal

An iOS sample in Swift that authenticates Azure AD B2C users and calls an API using OAuth 2.0
https://aka.ms/aadb2c
MIT License
45 stars 22 forks source link

Not a B2C Authority. Trying to initialize access token when missing access token field. #54

Closed ronnie-codes closed 3 years ago

ronnie-codes commented 3 years ago

I'm trying to setup Google as an identity procider in my Azure B2C AD and pass an access token into my iOS app.

I've mirrored the sample app you've provided, and I've configured my B2C AD according to these tutorials:

https://docs.microsoft.com/en-us/azure/active-directory-b2c/add-native-application?tabs=app-reg-ga https://docs.microsoft.com/en-us/azure/active-directory-b2c/add-sign-in-policy?pivots=b2c-user-flow https://docs.microsoft.com/en-us/azure/active-directory-b2c/idp-pass-through-user-flow?pivots=b2c-user-flow

My issue is that the MSAL library fails to initialize the access token in the result of acquireToken(). There is an internal error that isn't handled by the library, the library just logs an error to stdout.

Here is the error log:

TID=2581843 MSAL 1.1.17 iOS Sim 14.4 [2021-05-07 02:09:15] Creating Error with description: It is not B2C authority.
TID=2581843 MSAL 1.1.17 iOS Sim 14.4 [2021-05-07 02:09:15] Trying to initialize access token when missing access token field

Also worth noting. When running the user flow from the Azure portal with the reply URL set to https://jwt.ms, the token is returned successfully from Google Cloud to this page.

I'm not sure why the library is having issues retrieving the access token from the webview into the app.

Thank you for your time. If needed, I can provide code snippets.

ronnie-codes commented 3 years ago

Issue resolved. B2C AD skips returning an access token when scope is missing.