I have implemented my OAuth2 client myself. It works, I have client id, client secret and access token. I also have refresh token an can receive new access tokens from it.
But how to use these Strings with Google API for Java (Contacts API)?
I have created ContactsService service = new ContactsService("<var>test</var>");
It seams I have to provide OAuthParameters to service.setOAuthCredentials()
, but OAuthCredentials has no field for access token or refresh token. There is only setOAuthToken()
and setOAuthTokenSecret()
. :-(
Solution was not to use setOAuthCredentials()
. Instead:
service.setPrivateHeader("Authorization", "Bearer " + accessToken);