I have a refresh token issue in my app and i can not figuring out how to solve it. I've seen various posts about it but i still need some help. The authorization code i'm using is basically the Quick Start one.
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
private static final String TOKENS_DIRECTORY_PATH = "tokens";
protected final Credential authorize(final List<String> SCOPES) throws IOException, GeneralSecurityException {
final InputStream in = GoogleAPI.class.getResourceAsStream("/credentials.json");
final GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
final GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow
.Builder(GoogleNetHttpTransport.newTrustedTransport(), JSON_FACTORY, clientSecrets, SCOPES)
.setDataStoreFactory(new FileDataStoreFactory(new File(TOKENS_DIRECTORY_PATH)))
.setAccessType("offline")
.build();
final LocalServerReceiver receiver = new LocalServerReceiver.Builder().setPort(9000).build();
return new AuthorizationCodeInstalledApp(flow, receiver).authorize("user");
}
The above has been working fine up 'till the day google started responding with HTTP 400 Bad Request with the following message
{ "error" : "invalid_grant", "error_description" : "Token has been expired or revoked." }
I went thro this post Google OAuth “invalid_grant” nightmare — and how to fix it, i've tried deleting the credential and creating a new one. I've also tried deleting the tokens locally but without any success.
What am i missing here?