1

I am using the below code for verifying the google id token. It always giving me the below error. But with the same headers i am able to do the verification in POST MAN tool. Please help me to resolve this.

    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();
    }

Error:

Exception in thread "main" com.sun.jersey.api.client.UniformInterfaceException: GET https://www.googleapis.com/oauth2/v3/userinfo returned a response status of 401 Unauthorized

Harikrishnan
  • 7,765
  • 13
  • 62
  • 113
Vineesh P
  • 53
  • 5
  • Are you using the google apis java client library? I would think it would have a method for validation. That doesnt look like the corect end point for validing the token id – Linda Lawton - DaImTo Jul 01 '17 at 12:58

0 Answers0