magiclabs / magic-flutter

Apache License 2.0
10 stars 6 forks source link

Sign in With Apple Not Working #14

Closed jimvandijk closed 1 year ago

jimvandijk commented 1 year ago

I am trying to use the magic_ext_oauth plugin to sign in using Socials. I am using Google and Apple. The former sign in method works, but the latter doesn't. Upon debugging, realized the return value after logging in with pop-up returns null. Here is the code snippet we are using to sign in:

final configuration = moauth.OAuthConfiguration( provider: moauth.OAuthProvider.APPLE, redirectURI: "link.magic.app://", ); OAuthResponse response = await magic.oauth.loginWithPopup(configuration);

Trying to get the didToken by reading the idToken from response.magic?.idToken returns null.

I have tried using the sample demo app but Apple Sign in still doesn't work

wandriputra commented 1 year ago

I want to add more descriptions for @nziokajimkelly problem, I helped him debug your SDK, in magic_ext_oauth.dart I get this error after the user successfully authenticates with an Apple account.

image
Ariflo commented 1 year ago

Thanks @nziokajimkelly and @wandriputra, we're looking into this, will report back asap.

Ariflo commented 1 year ago

@nziokajimkelly @wandriputra The error (ie Failed to retrieve OAuth access token.) only appears when something has gone awry with the way things were setup with the third party OAuth provider, which in this case is Apple.

I suggest you review our documentation under the "Apple Setup" heading to make sure you've supplied the correct credentials to the form on your dashboard.

Also be sure your redirectURI is your actual callback url scheme, and remain unchanged for the rest. As called out in our flutter docs:

Screenshot 2023-02-02 at 3 39 51 PM

With regard to our demo app not working, we found a conditional logic error that prevented the app from navigating to the main screen. That said, we were still able to use Apple to login successfully with the latest version of magic_ext_oauth.

To test yourself, feel free to use the key provided in this demo in the flutter demo app and compare that to what is returned with your key.

One other thing to consider is to make sure you've placed your private key between a -----BEGIN PRIVATE KEY----- and ----END PRIVATE KEY----- on the form like so:

-----BEGIN PRIVATE KEY----- Your Apple Private Key goes here -----END PRIVATE KEY-----

wandriputra commented 1 year ago

I get this screen while using my private key from the Magic dashboard. seems the configuration is correct. @Ariflo Screenshot 2023-02-05 at 00 48 58

wandriputra commented 1 year ago

do you have an example app for flutter so we can do the same? just want to make sure setup for flutter is correct

Ariflo commented 1 year ago

do you have an example app for flutter so we can do the same? just want to make sure setup for flutter is correct

@wandriputra Yes, feel free to utilize our demo flutter app for testing and report back.

I encourage you to plug-in our sample app's API key as well to compare what is returned when attempting to login with Apple on the Flutter app.

wandriputra commented 1 year ago

@Ariflo demo api-key works fine but our api-key not working at all same error we get with the above screenshot. so the problem is with the configuration in our Magic Dashboard?

why does the web version work? and flutter version not.

wandriputra commented 1 year ago

Also be sure your redirectURI is your actual callback url scheme, and remain unchanged for the rest

@Ariflo how do you best way to define the redirectURI for iOS? I can't find it in your documentation tutorial

Ariflo commented 1 year ago

demo api-key works fine but our api-key not working at all same error we get with the above screenshot. so the problem is with the configuration in our Magic Dashboard?

If you are seeing the same error crop up when you plug-in your api-key to our demo flutter app, but crucially do not see it crop up when using our demo api-key with the same app; then this suggests something is possibly wrong in 2 places:

1 - Your configuration in the Magic Dashboard

OR

2 - Your configuration with the third party (ie. Apple)

Given the fact that you mentioned the web (ie. "test connection" button) works but the Flutter fails, I would investigate # 2 and check your setup with Apple.

how do you best way to define the redirectURI for iOS? I can't find it in your documentation tutorial

The redirectURI should be your app scheme (ie. "appName://"). See here for more details.

Ariflo commented 1 year ago

You're probably aware of this, so apologies for the repetition, but here is how we've setup Oauth in the demo app.

Ariflo commented 1 year ago

@wandriputra any updates here?

wandriputra commented 1 year ago

@Ariflo we have some issues with Apple in our account and our private key for sign-in with Apple. we Solve this by contacting Apple. Thanks for your help you can close this issue.

am-hernandez commented 1 year ago

Thank you for the followup @wandriputra !

@Ariflo I am closing the issue, thank you!