0
votes

I want to store access token in session and if session is store then set accessToken and get the current user using Google OAuth..

I got the code from Git Hub Click here. build on java eclipse maven build it war file and paste in tomcat.

View Java Code click here

Code Work perfectly. i dont know how to get access token from google response code.

when i click om button it redirects to google oauth and after redirect to my callback url it response like

https://localhost:8080/oauth/index.jsp?state=google&code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp7

from that code behalf if fetches the user information. but i need to store the access token which extract from that code. I got the reference from Google developers site but i can't figure out how to extract access token from that code and refresh access token to extend the token expiration.

or any other reference / tutorial for google o-auth that build on java web based plz share.

Click here for reference from google developers site enter image description here

1

1 Answers

0
votes

You can extract the access_token and expires_in from the returned GoogleTokenResponse, e.g., GoogleTokenResponse#getAccessToken().

Take a look at the documentation for GoogleTokenResponse.