How to create OAuthParameters from access token for Google Contacts API

457 views Asked by At

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(). :-(

1

There are 1 answers

0
Witek On BEST ANSWER

Solution was not to use setOAuthCredentials(). Instead:

service.setPrivateHeader("Authorization", "Bearer " + accessToken);