Reputation: 152
On Google AppEngine i have been through authentication for Google Docs ... access using AuthSub authshub.
We managed to AuthSubUtil.exchangeForSessionToken(..)
.
QUESTION: Is it possible to follow up and get Access to Google Drive using this token?
... new Drive.Builder(httpTransport, jsonFactory, credential);
Upvotes: 0
Views: 261
Reputation: 6034
I'm not sure if AuthSub works with the Google Drive API, but if it does, this code snippet should resolve your problem:
new Drive.Builder(httpTransport, jsonFactory, new HttpRequestInitializer() {
@Override
public void initialize(HttpRequest request) {
HttpHeaders headers = request.getHeaders();
// Not sure if this test is necessary as headers might never be null.
if (headers == null) {
headers = new HttpHeaders();
request.setHeaders(headers);
}
headers.setAuthorization("AuthSub token=\"<TOKEN>\"");
}
}).build();
Important: please be aware that AuthSub is being deprecated and you should try to migrate your application to use OAuth 2.0 as soon as you can.
Upvotes: 0