Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apple Sign in Issue #48

Open
guptahitesh121 opened this issue Oct 27, 2020 · 2 comments
Open

Apple Sign in Issue #48

guptahitesh121 opened this issue Oct 27, 2020 · 2 comments

Comments

@guptahitesh121
Copy link

guptahitesh121 commented Oct 27, 2020

I am getting an issue in production with Apple sign in for that I am not sure if that is something this plugin can handle. So I ask for help to understand the issue.

The issue is when the user is logged in in iPhone settings with Apple id and then I try to login using auth0, it starts the browser and instantly browser gets closed by launching a native dialog to login with the same user or to switch to a different user. If user selects the same user then it does not go back to the browser to complete the login flow. Here I believe browser is the one which redirects the user back to our application using deep linking with a payload and, in this case, the native apple sign in dialog not going back to the browser. I guess this plugin looks for only browser to send back the idToken to our app.

So, in this case after apple sign in nothing happens, user sees the login screen of our app again. When there is no user in iPhone then the complete flow is managed by browser and login happens successfully. I think because of the native interface of Apple sign in which kicks in without our control, this flow is interrupted and at the end our app does not receive any payload from the Apple servers.

Can you please suggest what is the problem here or any solution for this?

@mkolbusz
Copy link

mkolbusz commented Nov 11, 2020

@guptahitesh121 I have similar problem but one step further. When user click the Sign in with Apple button in application it opens browser with auth0 tenant domain and then redirect to appleid.apple.com and the native login dialog is showing. I click the Continue button, then select email to share, click Continue with Password, entering password and hit enter. After a while the dialog disappears, my app login page shows and in the terminal I have got error with following call stack:

[VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: PlatformException(Error, a0.session.failed_load, Failed to load url, null)
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:582:7)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:18)
<asynchronous suspension>
#2      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12)
#3      WebAuth.authorize.<anonymous closure> (package:flutter_auth0/src/webauth/index.dart:64:12)
<asynchronous suspension>
#4      WebAuth.authorize.<anonymous closure> (package:flutter_auth0/src/webauth/index.dart)
#5      _rootRunUnary (dart:async/zone.dart:1198:47)
#6      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#7      _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#8      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#9      Future._propagateToListeners (dart:async/future_impl.dart:725:<…>

My code is:

Auth0 auth = Auth0(baseUrl: 'https://tenant-domain.eu.auth0.com', clientId: 'XxxXXxxXxxXxxXXxxxxxXXXXXxxXxXx');
auth.webAuth.authorize({'connection': 'apple'});

And in the ios/Runner/AppDelegate.swift I have following code:

import UIKit
import Flutter
import flutter_auth0

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    if #available(iOS 10.0, *) {
      UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
    }
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }

  override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        return FlutterAuth0Plugin.application(app, open: url, options: options)
   }
}

And in ios/Runner/Info.plist I have added following code:

<array>
	<dict>
		<key>CFBundleTypeRole</key>
		<string>None</string>
		<key>CFBundleURLName</key>
		<string>auth0</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
		</array>
	</dict>
</array>

@guptahitesh121 I hope my code will help you some way.
Any ideas what's going wrong and causes that error?

@guptahitesh121
Copy link
Author

@mkolbusz This looks similar to the problem I am getting but I don't get any error in the console. Looking at the stack trace of the error that you are getting, it looks like the URL called by the platform is wrong may be it does not exist. Other than that I also don't have any clue.

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

No branches or pull requests

2 participants