I am trying to create a Google Sign In workflow, the problem i have, after the button click, the modal to select the account, i get the success callback and i can access the user basic profile.
The problem is, when i refresh the site. If i run auth2.isSignedIn.get() it always return false.
To be sure my code is not the problem, i copy this example from Google
https://github.com/googleplus/gplus-quickstart-javascript/blob/master/index.html
Enter the site with Google code, login, select my account from the modal and the site display my information but when i reload the site, the session disappear.
Maybe i am missing something, how we can persist the session so the user don't have to login every time we refresh the site.
Thanks!
For this you need to implement the authentication in a server and maintain the session using cookies
You can use node, passport to achieve this. Hope this helps.
Related
I followed the tutorial to Build JavaScript single-page apps with Microsoft Graph, and use it for my real project.
With this tutorial, I could able to create the web app for login user and create a calendar event. The problem is the session is always quickly expired as soon as I refresh so that I have to login again and again. Is there any way I can keep user still login after refresh browser. I wish it just like the google calendar id here that can keep user signed in even after fresh browser. Thanks.
Use localStorage to store the logged in user details. On refresh or the first visit to your site, first check to see if the details are available in local storage. If they are available, then log in the user automatically. Otherwise request the user to login and save the details in local storage.
I'm migrating from the Google sign-in platform library to the new Google Identity Services with one-tap sign in, but the website automatically logs the user out when they refresh or go to a different page.
This is the code that's present on every page that loads the one-tap sign in:
<div id="g_id_onload"
data-client_id="[CLIENT ID]"
data-callback="onSignIn"
data-auto_select="true">
</div>
Removing this just keeps the user logged out with no way to log back in. There is a cookie, g_state, that stores the user's login, as well as attributes to display the popup based on its presence, but working with this also keeps the user logged out with no way to log back in.
Is there any way to prevent automatic logout on refresh?
Setting a cookie to track user sign-in status to your site should do it.
A few things to be aware of:
Your callback handler will manage the signed-in or signed-out status for users, here OnSignIn.
The cookie name set by data-skip_prompt_cookie is used to suppress One Tap after the user successfully signs into your website -- you've already logged in right, so stop bothering me with One Tap prompts. So, after someone visits any page and signs in, you'll issue a cookie so that One Tap isn't displayed when the next page is loaded. You'd want to clear this cookie when they sign out of your website.
The data-skip_prompt_cookie helps you control when to display One Tap when you're using static HTML, when using JS you'd choose to display One Tap by calling google.accounts.id.prompt or skip calling it and displaying One Tap.
Avoid using or referencing g_state entirely, it currently helps manage how to display the UI and isn't intended to be used as a means to try and track signed-in or session status. Instead, track user sign-in using your own cookie and data-skip_prompt_cookie.
i have a project that have option to log in with facebook.
but this option only work for the admin of the site
whenever any other user want to log in the site a form will appear and ask some info. if full fill the form and click register it shows a error message.
Now i want to remove the form part from the website and want onclick login for all user. here is the link of the site
https://dev.metarank.com/
please help me to find the solution
thanks in advance
If I am not wrong to create a Facebook login button you need to create an app to obtain api keys, right?
If it is the case the problem could be the following:
After testing the login button you have to make the app publicly available by passing a review process from Facebook, and then anyone will be able to login to your website with a Facebook account.
As said: this is the process for standard apps, at the moment I am not sure at all about if it is exactly the same process for logins.
I am using a Google App Engine (Java) with Google Cloud Endpoints. I would like to use Endpoint's built in authentication, and am doing so successfully with Google Sign-In for Websites.
Can you change the sign-in button behavior so that upon clicking the button the user is redirected to the Google sign in page and back rather than a new window opening? This would really improve the UX, especially for mobile.
In addition, is it possible to redirect non logged-in users automatically to the sign in page?
AFAIK there is no possible way to get the login into the same window. You can definitely post a Feature Request for such a thing on our issue tracker here.
As to answer your second question, yes it is possible to send non logged-in users directly to the sign in. You just need to check, at the top of your handler, if the user is signed in, and kick off the authentication flow if he isn't.
I am following authentications steps for AMS as described here:
http://azure.microsoft.com/en-us/documentation/articles/mobile-services-html-how-to-use-client-library/#caching
From Kendo UI mobile app (Javascript)
I can log in using Google as an authentication provider using client.login("google"), execute authenticated AMS custom API calls
and also doing client.Logout() via button, that seems to successfully disconnect me from AMS
On subsequent client.login(), however, I do not get the Google account login window. It is seemingly stored in a cookie and the user is logged in automatically, thus not giving me a chance to log in as another user.
I was wondering what additional actions besides client.Logout() I must do to initiate the Google login screen on the next session after the user decided to logout. I do not want to force the user out of his Google account, as this would be impolite, just log him out of my application.
I know this question is old, but since it is not answered and I found it out recently I decided to post the answer here.
When you go to google.com you can add another account (top right icon). After that you can choose after each logout which account you want to use for your application to login. And you can even add other accounts to log in.