https://developers.google.com/accounts/docs/OAuth2InstalledApp
次のリンクを使用して、WebビューでGoogleアカウントにサインアップするようにユーザーに提供しています
webview.loadUrl("https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&state=%2F&response_type=code&redirect_uri=urn:ietf:wg:oauth:2.0:oob&client_id=706645665586.apps.googleusercontent.com");
これには、Google APIコンソールで指定されたクライアントIDとリダイレクトURIが含まれています。つまり、リダイレクトURIの選択 https://developers.google.com/accounts/docs/OAuth2InstalledApp
最後に、view.getTitle()を使用して、ブラウザのタイトルバーに返される認証コードを取得します。
その後、送信するには別のリクエストが必要です。実際のリクエストは次のようになります。
POST /o/oauth2/token HTTP/1.1
Host: accounts.google.com
Content-Type: application/x-www-form-urlencoded
code=4/y_jtre05wvb6QSPo0Tkx5AbLfWB
client_id=706645665586.apps.googleusercontent.com
client_secret={client_secret}&
redirect_uri=urn:ietf:wg:oauth:2.0:oob
grant_type=authorization_code
だから今HTTPPOSTリクエストをしている間..
DefaultHttpClient httpcl = new DefaultHttpClient();
HttpPost httpp = new HttpPost("https://accounts.google.com/o/oauth2/auth");
List<NameValuePair> a = new ArrayList<NameValuePair>();
a.add(new BasicNameValuePair("code", "4/y_jtre05wvb6QSPo0Tkx5AbLfWB"));
a.add(new BasicNameValuePair("client_id", "706645665586.apps.googleusercontent.com"));
try {
StringEntity mEntity = new StringEntity("");
mEntity.setContentType(" application/x-www-form-urlencoded");
httpp.setEntity(mEntity);
httpp.setEntity(new UrlEncodedFormEntity(a));
HttpResponse response1 = httpcl.execute(httpp);
String response = EntityUtils.toString(response1.getEntity());
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
だから私は悪いトークンの応答を得ています...私は昨日からこれを試していますそして提案と助けをいただければ幸いです..私の主な目的はAndroidのGmailアカウントを使用してユーザー情報を取得することです