I am trying to get data of user of Google AdSense using OAuth2 and I have followed all the Documentation which is here.
And I successfully get all response which is expected but the problem is that the refresh token is expired within access token as access token expires after 1 hour and I'm unable to make another access token request from refresh token because it also expires.
In one line, Refreh Token expires after 1 hour and user needs to login again. That's main problem.
The Code I have tried to get access token from refresh token:
public TokenResponse refreshAccessToken(String refreshToken) throws IOException {
TokenResponse response = new GoogleRefreshTokenRequest(
new NetHttpTransport(),
new JacksonFactory(),
refreshToken,
"your clientId",
"your clientSecret")
.execute();
System.out.println("Access token: " + response.getAccessToken());
return response;
}
I have tried many searches but they didn't help. If there is any other method to get the access token, please help me to reach out there.
Thanks In Advance.
Any other working way would be Gold for me.
=========================== UPDATE ========================
I have got my mistake in my project.