aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.36k stars 2.09k forks source link

Support Google auth in Cordova apps #1126

Open Birowsky opened 5 years ago

Birowsky commented 5 years ago

Basic Cognito feature request

In a Cordova app, currently there is no way to use Google to authenticate user into a Cognito user pool.

In web-apps, the hosted ui approach works nicely, but Google has banned the use of in-app browser for mobile apps. Now, altho there are AWS libraries that solve auth in mobile apps, there is no solution for Cordova apps.

Let's talk about a workaround:

If we use the cordova-plugin-googleplus, we can retrieve a sufficient set of data to authenticate the user:

 email          // 'eddyverbruggen@gmail.com'
 userId         // user id
 displayName    // 'Eddy Verbruggen'
 familyName     // 'Verbruggen'
 givenName      // 'Eddy'
 imageUrl       // 'http://link-to-my-profilepic.google.com'
 idToken        // idToken that can be exchanged to verify user identity.
 serverAuthCode // Auth code that can be exchanged for an access token and refresh token for offline access
 accessToken    // OAuth2 access token

I just need some guidance to accomplish the whole thing. Is there maybe a combination of adminCreateUser and adminInitiateAuth that I can do to end up with Cognito user pool session consisting of access , id, and refresh tokens?

engharb commented 5 years ago

@powerful23 , @yuntuowang I'm looking to hear from you soon.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Birowsky commented 4 years ago

Need this to track progress

sebinbenjamin commented 3 years ago

any updates on this ?

Lokiejim1 commented 2 years ago

Looking for this exact capability. Has anything been added on this since 2018?

tannerabread commented 1 year ago

Hi @Birowsky, @Lokiejim1 I've been working on another issue similar to this but using the cordova-plugin-customurlscheme to accomplish Google Auth flows and get redirected back to the app. I am still trying options to make this seamless, but currently I have been able to return the code/state from either Hosted UI with Auth.federatedSignIn() or directly from Google with Auth.federatedSignIn({ provider: 'Google' }) and log the user in to Amplify.

Just want to verify, from what I read in that article and from what you said, Google only banned the use of an in-app browser for logging in.

Can you confirm if you would just like to see some way to use Google federated signIn with Amplify or if you were looking for something else?

tannerabread commented 1 year ago

Just commenting to link the 2 issues, but I did a really deep dive into this problem for #10301 and have a pretty detailed README on where we get caught up . The part of the README I linked has a workaround that is sort of hacky but gets the login to work.