nativescript-oauth2 icon indicating copy to clipboard operation
nativescript-oauth2 copied to clipboard

iOS Google Login Blank Page

Open demolot opened this issue 5 years ago • 9 comments

Hi there,

I've been trying for the couple days to get the Oauth 2.0 to work with Google on iOS unfortunately i wasn't able to make it to work.

This is the result i have once i've press the login:

image

No error appears on the console, or any warning, just a blank page. I've copy the exact lines from the TypeScript example and so far nothing seems to be working. (I created a new project on google and added the right clienID and redirectUri.

Facebook login works like a charm. Can someone please help me?

Thank you in advance

Please find the code that i've used both on the auth-service.ts:

function configureOAuthProviderGoogle(){

const googleProviderOptions: TnsOaProviderOptionsGoogle = {
    openIdSupport: 'oid-full',
    clientId: '63412479515-rfh5tjsc5i2ndenh94t72l0g8mev7ckp.apps.googleusercontent.com',
    redirectUri: 'com.googleusercontent.apps.63412479515-rfh5tjsc5i2ndenh94t72l0g8mev7ckp:/auth',
    urlScheme: 'com.googleusercontent.apps.63412479515-rfh5tjsc5i2ndenh94t72l0g8mev7ckp',
    scopes: ['email']
};
const googleProvider = new TnsOaProviderGoogle(googleProviderOptions);
return googleProvider;

}

and the info.plist

<key>CFBundleURLTypes</key>
<array>
	<dict>
		<key>CFBundleTypeRole</key>
		<string>Editor</string>
		<key>CFBundleURLName</key>
		<string>org.nativescript.quickmatch</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<string>196774454843344</string>
			<string>com.googleusercontent.apps.63412479515-rfh5tjsc5i2ndenh94t72l0g8mev7ckp</string>
		</array>
	</dict>
</array>

demolot avatar Jan 20 '20 11:01 demolot

I have the same problem with a custom provider

panagulis72 avatar Jan 22 '20 15:01 panagulis72

If it can helps, I have the following errore in console:

topmost() is deprecated. Use Frame.topmost() instead

panagulis72 avatar Jan 22 '20 16:01 panagulis72

@alexziskind1 any suggestion?

panagulis72 avatar Jan 24 '20 09:01 panagulis72

Please test if this issue also occurs on android.

If you use the same configuration as in the DEMO the difference between google and facebook providers is the following:

  • Google: openIdSupport: "oid-full"
  • Facebook: openIdSupport: "oid-none"

This changes the way the "login page" is opened.

            switch (this.provider.options.openIdSupport) {
                case "oid-full":
                    delegate_1.TnsOAuthClientAppDelegate.setConfig(this, this.provider.options.urlScheme);
                    this.loginController = tns_oauth_native_view_controller_1.TnsOAuthLoginNativeViewController.initWithClient(this);
                    break;
                case "oid-none":
                    this.loginController = tns_oauth_login_webview_controller_1.TnsOAuthLoginWebViewController.initWithClient(this);
                    break;
                default:
                    this.loginController = tns_oauth_login_webview_controller_1.TnsOAuthLoginWebViewController.initWithClient(this);
                    break;
            }

Facebook will use TnsOAuthLoginWebViewController Google will use TnsOAuthLoginNativeViewController

I recently also had an issue with TnsOAuthLoginNativeViewController on iOS - I can imagine your issue is related to mine #116

Can you please give me some more information:

  • Do you use some nested router outlets?
  • How does you app.component.html look like?

When you try to open google login on iOS and check the logs. Do you find: Presenting view controllers on detached view controllers is discouraged

mpht avatar May 20 '20 13:05 mpht

I had encountered the same problem, same blank page on iOS after google login. At first, my app used a single Frame and everything worked well. But recently I started to use 2 Frames and the Google login did not work anymore.

@mpht I tried your solution and it worked well. Actually, your code makes much more sense for multiple frame app than original one.

imiskuf avatar Jun 06 '20 10:06 imiskuf

@demolot you can try to use my forked repository (https://www.npmjs.com/package/nativescript-oauth2-forked). It contains the code from #116 and some deprecation fix

imiskuf avatar Jun 06 '20 11:06 imiskuf

@imiskuf any chance you could create a PR? Your fork fixes things for me too

Burgov avatar Jul 10 '20 08:07 Burgov

Yes a PR on this would be great! Thanks for finding the fix

alexziskind1 avatar Jul 10 '20 12:07 alexziskind1

FYI I get this same outcome when I implement custom UIApplicationDelegate on version 3.0.1 . Not sure why its interfering.

eugv86 avatar Nov 04 '20 22:11 eugv86