alexziskind1 / nativescript-oauth2

Other
85 stars 93 forks source link

Oauth 2 - Google - After Sigin not redirected back to app #138

Open digifost opened 3 years ago

digifost commented 3 years ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

I have integrated the latest version of Oauth -2. After I hit the signin button for Google, it prompt me for login(already loggedin users) on chrome. After I select the login, the browser does not come back to App. It just opens google.com.

I am using exactly same code mentioned in the demo app except the client id and other keys. This used to work for me earlier, it suddenly stopped working. This is working fine on my phone, not working on emulator.

Is there any code involved?

digifost commented 3 years ago

@alexziskind1 ..Please help

yukesh0505 commented 3 years ago

include this at manifest activity tag

android:launchMode="singleTask"

email-nkishor commented 3 years ago

After Sigin not redirected back to app in IOS

OniQ commented 3 years ago

I also get following error, when should be redirected to app:

NativeScript encountered a fatal error: Uncaught TypeError: this.handleIncomingUrl is not a function
at
TnsOAuthClientAppDelegate.applicationOpenURLOptions(file: node_modules/nativescript-oauth2/delegate/index.ios.js:14:0) 
armache commented 3 years ago

Having the same issue - after sign in redirects to google.com

odedBartov commented 3 years ago

I have exactly the same problem. I have no clue how to fix this... did anybody succeded?

digifost commented 3 years ago

I am still waiting for the resolution

OniQ commented 3 years ago

I have exactly the same problem. I have no clue how to fix this... did anybody succeded?

I modified index.ios.js to make it work for now. Replaced this.handleIncomingUrl to TnsOAuthClientAppDelegate.prototype.handleIncomingUrl.

alexziskind1 commented 3 years ago

That's great! If that solves the problem then would you like to open a Pull Request?

OniQ commented 3 years ago

It works, but this is just a workaround. It's not right to call prototype directly.

OniQ commented 3 years ago

That's great! If that solves the problem then would you like to open a Pull Request?

It is a change in js file, generated after build. I don't now what should be changed in source, so can't open a pull request.

odedBartov commented 3 years ago

I have exactly the same problem. I have no clue how to fix this... did anybody succeded?

I modified index.ios.js to make it work for now. Replaced this.handleIncomingUrl to TnsOAuthClientAppDelegate.prototype.handleIncomingUrl.

Where are this file and this code? i can't find it in my project

OniQ commented 3 years ago

I have exactly the same problem. I have no clue how to fix this... did anybody succeded?

I modified index.ios.js to make it work for now. Replaced this.handleIncomingUrl to TnsOAuthClientAppDelegate.prototype.handleIncomingUrl.

Where are this file and this code? i can't find it in my project

At first I modified it directly in node_modules/nativescript-oauth2/delegate/index.ios.js I also found a way to fix it in source and created a pull request #139

odedBartov commented 3 years ago

I have exactly the same problem. I have no clue how to fix this... did anybody succeded?

I modified index.ios.js to make it work for now. Replaced this.handleIncomingUrl to TnsOAuthClientAppDelegate.prototype.handleIncomingUrl.

Where are this file and this code? i can't find it in my project

At first I modified it directly in node_modules/nativescript-oauth2/delegate/index.ios.js I also found a way to fix it in source and created a pull request #139

1) i already have your updated code, i didn't touched it but my current code is as your updated one and not the old one. 2) I am using android and not IOS, how can i fix this for android?

alexziskind1 commented 3 years ago

Confirmed this is an issue on Android, not on iOS. Unaware of a fix at this time. Open to review PRs.

OvidiuGuta commented 3 years ago

hi Alex @alexziskind1. I have the same issue as described above on ios with v3.0.1 of the plugin. The above fix worked for me as well even taught it should just be a temporary one as it's changing the .js file. So the PR motioned above that you close might be a valid one after all.

There was also a discussion in #135 that looks related even taught it says it's related to firebase.

cobreen commented 3 years ago

include this at manifest activity tag

android:launchMode="singleTask"

Did not solved the problem

kingjordan commented 3 years ago

I am having this issue on a new angular code share project with the android emulated app.

Angular 11.0.4, Nativescript 7.0.0, "nativescript-oauth2": "^3.0.3"

tried editing the androidManifest.xml file with both <data android:scheme="com.googleusercontent.apps.******-meqq8tqvl6v5em9a8pk8n4bbt0id64lv"/> and <data android:path"/auth" android:scheme="com.googleusercontent.apps.******-meqq8tqvl6v5em9a8pk8n4bbt0id64lv"/>

neither worked for returning to app

here is the google tnsOaProvider set up:

  public configureOAuthProviderGoogle(): TnsOaProvider {
    const googleProviderOptions: TnsOaProviderOptionsGoogle = {
      openIdSupport: 'oid-full',
      clientId: '******-meqq8tqvl6v5em9a8pk8n4bbt0id64lv.apps.googleusercontent.com',
      redirectUri: 'com.googleusercontent.apps.******-meqq8tqvl6v5em9a8pk8n4bbt0id64lv:/auth',
      urlScheme: 'com.googleusercontent.apps.******-meqq8tqvl6v5em9a8pk8n4bbt0id64lv',
      scopes: ['email'],
    };

I do not et any errors in the console when I open the debug tools via: devtools://devtools/bundled/inspector.html?ws=localhost:40000

From what I can trace, in the node_modules/nativescript-oauth2/delegate/index.android.js file line 3: args.activity.getIntent().getAction() is null when it should be android.intent.action.VIEW

the above "fix" from OniQ is only relevant for ios users even though the issue is with android as well.

christiannepomuceno commented 3 years ago

My code is working fine before in iOS but now its redirecting to a google page after sign-in instead back to app, if you press done the tokenResult will be null the error result will be "The login operation was canceled".

with error "Safari cannot open the page because the address is invalid."

Its working fine before, not sure what happen. We also have firebase plugin on our app

nativeB commented 3 years ago

any update on this issue on android?

nativeB commented 3 years ago

so don't know if this helps tested on two emulators with android 9 and 10, noticed it worked on 10 not 9 for me

kingjordan commented 3 years ago

Tried using this on Default Pixel 4 image on android studio with android 11, default pixel 3 image with android 10, and pixel 2 with android 9, none of them worked for google integration. Just logged user in to google account and did not redirect back to app.

I would be willing to put some time into this but I am not sure where to start, can someone help me identify where to start debugging this issue?

alexziskind1 commented 3 years ago

Thanks for offering to help @kingjordan . This could be an issue with Android API level support or AndroidX library detection. Take a look at the gradle file included with the plug-in and the previous versions of the file and how it was changed. Accepting PRs.

christiannepomuceno commented 3 years ago

This also happen on iOS after we implemented firebase for our push notification. After the user successfully logins it proceed to a goole search page instead of redirecting to the app.

kingjordan commented 3 years ago

Thanks for offering to help @kingjordan . This could be an issue with Android API level support or AndroidX library detection. Take a look at the gradle file included with the plug-in and the previous versions of the file and how it was changed. Accepting PRs.

@alexziskind1 thanks for the help getting started. I was not able to get any solution.

I tried the following:

  1. updating the dependencies in include.gradle to most current versions: image this did not change anything

  2. I added google play services because this doc indicates that we need it. so I added the following to app.gradle image and I added a before-plugins.gradle file with the following code: image

    I also tried with current version of play services v19 and again, no solution

  3. I tried downgrading the package and tried all version between 3.0.1 and 3.0.3 (current) I reviewed the code changes in all of the files in those commits' and could not find anything to help.

  4. Unfortunately, because of this issue with nativescript preview I am unable to confirm if this works on an actual device as others report.

I am not sure what else I can do to test this

thanks

christiannepomuceno commented 3 years ago

Any update on this? or can anyone recommend another plugin that works with firebase?

jacopo69 commented 3 years ago

Thanks to @OniQ for the iOS workaround. We hope it will be fixed soon.

vallemar commented 3 years ago

I have started today with this plugin and I have encountered the problem on IOS.

ShyshkovOleg commented 3 years ago

@christiannepomuceno , did you managed to fix it. I have the same error. @alexziskind1 Could you help us with this? Is this possible to retrieve email with this plugin ?

stefanoScalzo commented 3 years ago

@alexziskind1 This is an IOS issue and I've tried to also add return TnsOAuthClientAppDelegate.prototype.handleIncomingUrl(url); to the index.ios.js in the delegate folder but it still brings me to the google page. When can we expect a fix for this?

osorionicolas commented 3 years ago

Any update on this? Same problem for IOS