Question

I am trying the JAVA example of Google Drive SDK API(https://developers.google.com/drive/examples/java) on my localhost before deploying it on GAE. However, i am receiving the following error.

java.lang.RuntimeException: No refresh token found. Re-authorizing.

1- How should i configure the Client API access? 2- how should i the secret file should look like?

Was it helpful?

Solution

The issue is not about how you configure your app's credentials.

The example is either not receiving a refresh token or not persisting it permanently. Once you are redirected to the URL built by the following url builder, you should receive back a refresh_token as well. This token should be persisted permanently to be used by the client library to refresh access tokens.

GoogleAuthorizationCodeRequestUrl urlBuilder =
  new GoogleAuthorizationCodeRequestUrl(
      secrets.getWeb().getClientId(),
      secrets.getWeb().getRedirectUris().get(0),
      scopes)
      .setAccessType("offline")
      .setApprovalPrompt("force");

There is probably a problem on the flow, we're making a few changes to the samples. I will try to address your problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top