How to make google auto login functionality in Spring boot project?

Viewed 441

I have applied google login functionality in my spring project. which functions like-- a user login in with google account the details of user saved into database. But, I have a requirement to auto login google account user who previously logged in with the account. but I don't know how to do that. One way to do that (what I think) is to save cookie, but after that how a user logged in using that cookie.

I am using Spring Security Oauth2 got google sign in. After searching I got, openid is used to autologin. But I don't know how to apply and implement it.

1 Answers

Look into refresh tokens. Once the user been inactive for 2 hours (as by default), his token expires. He can obtain a new one if he has a refresh token, which you can store on your side when you authorize that user.

Related