refresh token
Hi, it was nice demo but let me know why you haven't used "google.client.user-authorization-uri" url. Because i just debug your code and found that only we are getting AccessToken but it will expire in an hour may be so definately we need refresh token as well.
@mangomi Hey !
Do you have any idea how we can creatEvent based on the previously written code ?
Thank you very much
how to hit api in post for Google calendar? and how we can set time in that
Hi, it was nice demo but let me know why you haven't used "google.client.user-authorization-uri" url. Because i just debug your code and found that only we are getting AccessToken but it will expire in an hour may be so definately we need refresh token as well.
Hi, I know it was long ago that u asked this, but today I had to implement this and here it goes.
Google only provide refresh token when u ask for offline accessType on your flow, so you gonna have to make ur authorize() function look like this:
private String authorize() throws Exception {
AuthorizationCodeRequestUrl authorizationUrl;
if (flow == null) {
Details web = new Details();
web.setClientId(clientId);
web.setClientSecret(clientSecret);
clientSecrets = new GoogleClientSecrets().setWeb(web);
httpTransport = GoogleNetHttpTransport.newTrustedTransport();
flow = new GoogleAuthorizationCodeFlow.Builder(httpTransport, JSON_FACTORY, clientSecrets,
Collections.singleton(CalendarScopes.CALENDAR))
.setAccessType("offline")
.build();
}
authorizationUrl = flow.newAuthorizationUrl().setRedirectUri(redirectURI);
System.out.println("cal authorizationUrl->" + authorizationUrl);
return authorizationUrl.build();
}
Hope this helps someone looking for answers!