Google IDトークンを検証するために以下のコードを使用しています。それは常に私に以下のエラーを与えます。しかし、同じヘッダーを使用して、POST MAN ツールで検証を行うことができます。これを解決するのを手伝ってください。
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
WebResource service =
client.resource("https://www.googleapis.com/oauth2/v3/userinfo");
try {
ClientResponse response = service.header("Authorization",
"Bearer ya29.Glt6BGkbIzLEjeeQ5Q8O51Jh7-PFD3hVLM7PORixSTVFY-
iduKE8HmK8KMtzYz-
yJ9rUqo_xY9yVKl5b6CAiTNAtFErb0bZJB3vX6vPZVRPwbY6kVCIDbukDc9FA")
.header("Content-Type", "application/x-www-form-urlencoded")
.header("Accept",
"Accept=text/html,application/xhtml+xml,
application/xml;q=0.9,*/*;q=0.8").get(ClientResponse.class);
} catch (Exception e) {
e.printStackTrace();
}
エラー:
スレッド「メイン」の例外 com.sun.jersey.api.client.UniformInterfaceException: GET https://www.googleapis.com/oauth2/v3/userinfoが 401 Unauthorized の応答ステータスを返しました