Apache HttpClientを使用してGoogleカレンダー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"
これは非ユーザインタラクティブなプロセスであり、1時間ごとにカレンダーをチェックし、有効期限が切れている資格情報を持たないようにする必要があります。 – James