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

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

Open
digifost opened this issue Oct 22, 2020 · 31 comments
Open

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

digifost opened this issue Oct 22, 2020 · 31 comments

Comments

@digifost
Copy link

digifost commented Oct 22, 2020

Which platform(s) does your issue occur on?

  • Android - Angular
  • iOS/Android versions
  • What type of device - Emulator

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

  • CLI: 7.0.4
  • Cross-platform modules: (check the 'version' attribute in the
    node_modules/tns-core-modules/package.json file in your project)
  • Runtime(s): (look for the "tns-android" and "tns-ios" properties in the package.json file of your project)
  • Plugin(s): (look for the version numbers in the package.json file of your
    project and paste your dependencies and devDependencies here)

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?

  • provide a code example to recreate the problem
  • (EVEN BETTER) provide a .zip with application or refer to a repository with application where the problem is reproducible.
@digifost
Copy link
Author

@alexziskind1 ..Please help

@yukesh0505
Copy link

include this at manifest activity tag

android:launchMode="singleTask"

@email-nkishor
Copy link

After Sigin not redirected back to app in IOS

@OniQ
Copy link

OniQ commented Nov 5, 2020

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
Copy link

armache commented Nov 7, 2020

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

@odedBartov
Copy link

odedBartov commented Nov 8, 2020

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

@digifost
Copy link
Author

digifost commented Nov 8, 2020

I am still waiting for the resolution

@OniQ
Copy link

OniQ commented Nov 8, 2020

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
Copy link
Owner

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

@OniQ
Copy link

OniQ commented Nov 8, 2020

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

@OniQ
Copy link

OniQ commented Nov 8, 2020

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
Copy link

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 OniQ mentioned this issue Nov 9, 2020
4 tasks
@OniQ
Copy link

OniQ commented Nov 9, 2020

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
Copy link

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
Copy link
Owner

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

@OvidiuGuta
Copy link

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
Copy link

cobreen commented Dec 17, 2020

include this at manifest activity tag

android:launchMode="singleTask"

Did not solved the problem

@kingjordan
Copy link

kingjordan commented Jan 1, 2021

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
Copy link

christiannepomuceno commented Jan 4, 2021

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
Copy link

nativeB commented Jan 5, 2021

any update on this issue on android?

@nativeB
Copy link

nativeB commented Jan 6, 2021

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
Copy link

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
Copy link
Owner

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
Copy link

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
Copy link

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

  1. 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.

  2. 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
Copy link

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

@jacopo69
Copy link

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

@vallemar
Copy link

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

@ShyshkovOleg
Copy link

@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
Copy link

@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
Copy link

osorionicolas commented May 18, 2021

Any update on this? Same problem for IOS

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

Successfully merging a pull request may close this issue.