Apache HttpClient를 사용하는 Google Calendar API와 같은 인증이 필요한 Google API를 호출 할 수 있는지, Google 코드 또는 라이브러리가 없는지 알고 싶습니다. (그리고 코드가 필요합니다)Apache HttpClient를 사용하여 Google auth API를 호출하십시오.
이것은 내가 지금까지 가지고있는 코드이며, 인증 오류가 발생합니다. 사용자/암호로 무엇을 사용합니까?
HttpPost request = new HttpPost("https://www.googleapis.com/calendar/v3/users/me/calendarList/primary?key=mykey");
DefaultHttpClient client = new DefaultHttpClient();
client.getCredentialsProvider().setCredentials(
new AuthScope(AuthScope.ANY),
new UsernamePasswordCredentials(user, password));
HttpResponse response = client.execute(request);
오류 :
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
참고 이것은 비 사용자 대화식 프로세스이므로 매시간 일정을 확인하고 만료되는 자격 증명이 필요하지 않습니다. – James