I'm trying to get a Google+ user's info using
https://www.googleapis.com/oauth2/v1/userinfo?alt=json
I pass the access token I previously obtained:
URL googleURL = new URL("https://www.googleapis.com/oauth2/v1/userinfo?alt=json");
URLConnection googleConn = googleURL.openConnection();
googleConn.setAllowUserInteraction(false);
googleConn.setDoOutput(true);
**googleConn.setRequestProperty("Authorization", "Bearer "+accessToken);**
BufferedReader rd = new BufferedReader(new InputStreamReader(googleConn.getInputStream()));
String result = "";
while(rd.ready())
result += rd.readLine();
rd.close();
But it gives me the HTTP error code 401 (invalid headers).
Is this the right way to pass the access token in the header?
googleConn.setRequestProperty("Authorization", "Bearer "+accessToken);