Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Authentication error when receive redirect from acquireToken #6

Open
ductranit opened this issue Nov 28, 2019 · 5 comments
Open

Authentication error when receive redirect from acquireToken #6

ductranit opened this issue Nov 28, 2019 · 5 comments

Comments

@ductranit
Copy link

ductranit commented Nov 28, 2019

I tried to follow the document & an example in this plugin. User can sign in in b2c but it always in the redirect step with the exception Authentication error.
My redirect url: msauth.com.my.package://auth
I also set the CFBundleURLTypes & LSApplicationQueriesSchemes like the document & example, but still doesn't work.
My code:

Future<String> acquireToken() async {
    if (pca == null) {
      pca = await PublicClientApplication.createPublicClientApplication(
          _clientId,
          authority: _authority);
    }
    try{
    await pca.logout();
    } on MsalException catch(e){
        LogUtil.e(e);
    }

    try {
      return await pca.acquireToken([
        "https://mytenant.onmicrosoft.com/b2capi/user_impersonation"
      ]);
    } on MsalUserCancelledException catch(e) {
      LogUtil.e(e);
    } on MsalNoAccountException catch(e){
      LogUtil.e(e);
    } on MsalInvalidConfigurationException catch(e){
      LogUtil.e(e);
    } on MsalInvalidScopeException catch(e){
      LogUtil.e(e);
    } on MsalChangedClientIdException catch(e){
      LogUtil.e(e);
    }on MsalUninitializedException catch(e){
      LogUtil.e(e);
    }on MsalInitializationException catch(e){
      LogUtil.e(e);
    } on MsalException catch(e){
      LogUtil.e(e);
    }
  }

Do you have any idea to debug the detail problem?

@ductranit ductranit changed the title Authentication error when receive redirect Authentication error when receive redirect from acquireToken Nov 28, 2019
@mswehli
Copy link
Member

mswehli commented Dec 13, 2019

@ductranit sorry forgot to reply sooner. Do you get any errors in the log output? Also which version of iOS and please confirm if your xcode and flutter are all updated and using the latest versions.

@dustincatap
Copy link

dustincatap commented Mar 22, 2020

Hi, I'm having also this same issue on iOS. It doesn't show a webpage, it immediately throws an exception when acquiring token.

I've already add the required items inInfo.plist

<key>CFBundleURLTypes</key>
<array>
	<dict>
		<key>CFBundleURLSchemes</key>
		<array>
			<string>msauth.com.mycompany.sample</string>
		</array>
	</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
	<string>msauthv2</string>
	<string>msauthv3</string>
</array>

I've already changed the deployment target to iOS 11 for both project and the added this platform :ios, '11.0' in the Podfile.

Running on iPhone 8+ (iOS 12), Xcode 11.3.1, Flutter 1.12.13+hotfix8

@ductranit
Copy link
Author

@ductranit sorry forgot to reply sooner. Do you get any errors in the log output? Also which version of iOS and please confirm if your xcode and flutter are all updated and using the latest versions.

Sorry I didn't get github email notification until now. I'm not working on this project now.
I decided to use the webview to show custom b2c authentication website instead of this library.

@eladcandroid
Copy link

Does anyone know about a solution?

@mswehli
Copy link
Member

mswehli commented Jul 9, 2020

Hi @eladcandroid, sorry about the delay in getting back, just realised i actually didnt have notifications properly set up, which is why i kept missing so many >_<
For the time being, unfortunately i'm a bit short on time, however I have a rather extensive rewrite planned so unfortuantely it will have to wait until this. I'll try to get started on it soon

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants