Android 용 Google 드라이브로 작업 할 응용 프로그램을 만들고 있습니다.setJsonHttpRequestInitializer 메소드가 Drive.Builder 유형에 대해 정의되지 않았습니다. Android
인터넷에서 몇 가지 예를 검색했지만 모두 동일합니다. 다음과 같은 오류가 나타납니다.
Object Drive.Builder does not have method setJsonHttpRequestInitializer.
Google 드라이브 API V1 및 V2를 사용하여 운이 좋음을 테스트했습니다.
어디에 문제가 있습니까?
출처 :
private Drive getDriveService(String accountName) {
HttpTransport ht = AndroidHttp.newCompatibleTransport();
JacksonFactory jf = new JacksonFactory();
Credential credential = new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accountName);
Drive.Builder b = new Drive.Builder(ht, jf, null);
b.setJsonHttpRequestInitializer(new JsonHttpRequestInitializer() {
@Override
public void initialize(JsonHttpRequest request) throws IOException {
DriveRequest driveRequest = (DriveRequest) request;
driveRequest.setPrettyPrint(true);
driveRequest.setOauthToken(accountName);
driveRequest.setKey(API_KEY);
}
});
return b.build();
}
사용이 구글-API - 자바 클라이언트 1.12.0 베타 경우
다운로드 및 수입 구글-API - 자바 클라이언트 1.11 setJsonHttpRequestInitializer 방법은 정의되지 않은 것으로 나타났습니다 .0-beta
하지만 이제는 다음과 같이 나타납니다. 설치된 애플리케이션에 클라이언트 ID 사용 : 클라이언트 ID.
다음Exceptioncom.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized
{
"code" : 401,
"errors" : [ {
"domain" : "global",
"location" : "Authorization",
"locationType" : "header",
"message" : "Invalid Credentials",
"reason" : "authError"
} ],
"message" : "Invalid Credentials"
}
인 프로젝트 소스 키 API :
com.google.api.client.http.HttpResponseException: 403 Forbidden
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured"
}
],
"code": 403,
"message": "Access Not Configured"
}
}
간단한 API 액세스를 사용
http://www.sendspace.com/file/an6xxy
뭐가 문제, 인증서 지문 (SHA1)와 아마 뭔가?
Google에서 calendar-android-sample을 시도합니다.
Google api 콘솔에 등록 앱에 문제가있는 것 같습니다.
어디서 샘플을 얻을 수 있습니까?
샘플을 Android에서 디버그 모드로 실행 한 후 "액세스가 구성되지 않음"이 표시됩니다.
예, 도움이되었습니다. 그러나 이제는 Access가 구성되지 않습니다. Google 드라이브 용 Google API 콘솔에서 API 키를 작성하고 Manifets에서 작성했지만 행운은 없습니다. Exceptioncom.google.api.client.googleapis.json.GoogleJsonResponseException : (403) 금지 { "코드": 403, "오류": [{ "도메인": "usageLimits" "메시지": "구성되지 않음 액세스", "이유": "accessNotConfigured" } ], "message": "Access Not Configured" } – user1826780
드라이브 API는 인증을 위해 API 키를 사용하지 않고 대신 https://developers.google.com/android/google에서 설명한 인증 토큰이 필요합니다. -play-services/authentication –
더 많은 정보가 추가 되었습니까? – user1826780