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

googleApi: determine Logged In without going through Login process when user is not Logged In #25

Closed
matthewkooshad opened this issue Sep 24, 2018 · 10 comments

Comments

@matthewkooshad
Copy link

Login, then call login again. It will not present the UI. If tokens are cached and are valid, the UI will not be presented until the credentials are expired

the problem about the above is that before the initial "Login" @Clancey said to do (24),, how can i check if the user has Logged in (without sending the user to go Login)? i only want to send the user to the Login page to Login if they are not Logged in. thanks!

@matthewkooshad
Copy link
Author

if the app terminates, then the UI is getting presented. so, it seems it's only cached while the app is running in the foreground and background, but once the app is closed, then it will present the UI again for the user to choose the google account to login with. so, this is a 2nd problem.

so, for the first problem, we store on the device's user prefs that the user has a google account used before.

but, for the the 2nd issue stated in this comment, how do i cache the tokens and check for valid without going to the UI again for the user to choose their account again? this is the experience i am seeing when using googleApi.authenticate()

@Clancey
Copy link
Owner

Clancey commented Sep 25, 2018

I cannot duplicate this. Using the sample, on iOS and Android if I log into an account. next time I press login the UI is not shown. What platform are you trying this on? iOS Simulator has had a bug for years, if you don't specify entitlements it will not let you securely save tokens. So this could happen on the iOS Simulator.

@matthewkooshad
Copy link
Author

matthewkooshad commented Sep 25, 2018 via email

@Clancey
Copy link
Owner

Clancey commented Sep 25, 2018

I have been debugging. Starting and stoping the debugger. That kills the processes

@Clancey
Copy link
Owner

Clancey commented Sep 25, 2018

If you look at the authenticate code, it loads the cached account. If it is still valid, it returns and never presents the UI: https://github.com/Clancey/simple_auth/blob/master/simple_auth/lib/src/oauth/oauthApi.dart#L60-L72

@Clancey
Copy link
Owner

Clancey commented Sep 25, 2018

I would recommend cloning the source, putting some breakpoints in there and see what happens for you.

@matthewkooshad
Copy link
Author

matthewkooshad commented Sep 25, 2018 via email

@matthewkooshad
Copy link
Author

@Clancey you're right about that example performing as i'm looking for. i don't know what i'm doing wrong.

@Clancey
Copy link
Owner

Clancey commented Sep 25, 2018

What provider are you using? A custom one? If so, it is most likely not setting the RefreshToken or the Expiration on the account.

@matthewkooshad
Copy link
Author

sorry, i don't understand to answer that. but, i did want to report back in case someone encounters this problem as well. for me, it was a scope issue of where this instance was declared:
final simpleAuth.GoogleApi googleApi = new simpleAuth.GoogleApi(,,,
when i relocated it to the same function where the below statement happens, then it was working as the example, giving the desired result. i think i'm fine with the result of the code on this, so i will not be investigating why for now.
var user = await googleApi.getUserProfile();

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

No branches or pull requests

2 participants