Jak korzystać z klucza API dysku Google, aby uzyskać dostęp do zawartości dysku z aplikacji na Androida?
Nie mogę uzyskać dostępu do dysku Google. Stworzyłem KLUCZ API w konsoli Google API i włączyłem API i SDK Google Drive. Gdzie mogę ustawić ten klucz API w kodzie?
Kreator dysków nie masetJsonHttpRequestInitializer
metoda. Gdzie mogę ustawić KEY? Czy istnieją alternatywy?
private Drive getDriveService(String token) {
HttpTransport ht = AndroidHttp.newCompatibleTransport();
JacksonFactory jsonFactory = new JacksonFactory();
Credential credentials = new GoogleCredential().setAccessToken(token);
Drive.Builder b = new Drive.Builder(ht, jsonFactory, credentials);
b.setHttpRequestInitializer(credentials);
return b.build();
}
Uzyskiwanie:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "usageLimits",
"message" : "Access Not Configured",
"reason" : "accessNotConfigured"
} ],
"message" : "Access Not Configured"
}