Hi,
Sorry for that I am facing issues replying privately, I provide
the original email content and the information you need as below:
---------------------------------------------------


Wayne Tao
Sep 10, 2020, 1:34:37 PM (yesterday)



to [email protected]
Hi Team,

I have an issue about refresh user token expired time, I realize that user
token can only use for one hour then it will expired, so I write a function
to auto refresh token when it going to expired.

*Here's the code:*
GoogleOAuth auth = dao.getGoogleAuth();
System.out.println(String.format("Auth expired date:%s",
  new Date(auth.getExpirationTimeMillis()).toString()));
//get the original UserCredentials
UserCredentials credentials = auth.toUserCredentials();
credentials.refresh();
AccessToken accessToken = credentials.refreshAccessToken();

System.out.println("current time:" + new Date().toString());
System.out.println(String.format("Auth new expired date:%s",
  accessToken.getExpirationTime().toString()));
GoogleOAuth newAuth = GoogleOAuth.newBuilder(credentials.getClientId())

.setClientSecret(config.getClientSecret()).setRefreshToken(accessToken.getTokenValue())
  .setAccessToken(credentials.getAccessToken().getTokenValue())

.setExpirationTimeMillis(accessToken.getExpirationTime().getTime()).build();
biz.getMutator().mutateConnectGoogle(newAuth);
Collection<String> accountIds = newAuth.getAllAdAccounts(true);
GoogleCache.refreshAccountAndCampaignCache(newAuth, credentials,
accessToken, accountIds);

*The output got from Google:*
Auth expired date:Thu Sep 10 13:35:09 CST 2020
current time:Thu Sep 10 12:41:48 CST 2020
Auth new expired date:Thu Sep 10 13:35:10 CST 2020

I got the new token after run the auto refresh function, but the expired
time was not changed, I am not sure whats problem about it.




[image: adsapiforumadvisor's profile photo]
adsapiforumadvisor
Sep 10, 2020, 11:37:17 PM (yesterday)



to Wayne Tao, [email protected]
Hi Wayne,

Thank you for reaching out. I see that you're encountering a continuously
invalidating refresh token. Could you check that you haven't hit these
limits <https://developers.google.com/identity/protocols/oauth2#expiration> for
refresh tokens? If not, could you provide us with the request and response
logs for where you encounter this issue? For privacy you can provide this
to us by clicking "reply privately to author".

Thank you,
-------------------------------------------------------

we never reach the refresh tokens before, so I provide the request and
response logs to you:

Request:
client_id:
125997677546-l16cgrq8q5a6h9s6v45har09mqvi4fmk.apps.googleusercontent.com
client_secret:_fsiHdYW4Bocv85TNegesZMn
refresh_token:ya29.a0AfH6SMBUp6xG3XPOa9Pi0enziyIPvYc5n_lVw2bckuyJhJfGmeKRthygQ1dOxtZWZH7je3SAwRkYDQ2jjlGr79vgIIBClrvkmodl7DpGFrhpidFLrkVue-0X-XcByBVAE-GSDUQ5xWO5Htvf8BEuoK_VggjSpcSiXEA
grant_type:refresh_token
accessToken:AccessToken{tokenValue=ya29.a0AfH6SMCP1kKi0rQOx8wSnuwWfEtTCiJXfdKNPpKH30i16L7ODViJHbnvprgXT98WwvVjVPKbMC78znjIP1M7QtHbXyxCL4Puj7RpU9DMy3AkGpd5Iw21NDkxecP5DwVkvmLGm_POE06_sEiysUDTT-VuDoGmEkCgpkU,
expirationTimeMillis=1599805492696}
transportFactory:com.atfone.ads.wrapper.GoogleOAuth$DefaultHttpTransportFactory
tokenServerUri:https://oauth2.googleapis.com/token


Response:
GenericData{classInfo=[],
{access_token=ya29.a0AfH6SMCJdKXj_-Q9GUREE9_tTzwdpq827lC7w3i9yxdfinGUil9vb3_EMycjHXVEVsKFWJyN4DSSk1aqmFzrGNzB9gAoLqmSVuepoMbp0-O4bfMaRhs7ZmervOE1VPiN4ypNLcS1EFUnqC-ZNwad0yhUJsLawjPhqGo,
expires_in=1843, scope=https://www.googleapis.com/auth/userinfo.profile
openid https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/adwords, token_type=Bearer,
id_token=eyJhbGciOiJSUzI1NiIsImtpZCI6IjNmMzMyYjNlOWI5MjhiZmU1MWJjZjRmOGRhNTQzY2M0YmQ5ZDQ3MjQiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiIxMjU5OTc2Nzc1NDYtbDE2Y2dycThxNWE2aDlzNnY0NWhhcjA5bXF2aTRmbWsuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJhdWQiOiIxMjU5OTc2N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=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/CANN7bspoOV%3DUXWE50ZKB-oVfXPuqWWD2sbt0yvyaeJb44J5zkA%40mail.gmail.com.

Reply via email to