0

I am trying to integrate google in my android app. I am using oauth for retriving request token, access token. I want User's FirstName, LastName, ScreenName, Email. Here is what I am trying to do,

public static final String CLIENT_ID = "XXXX";
public static final String CLIENT_SECRET = "XXXX";
private static final String SCOPE = "https://www.googleapis.com/auth/userinfo.profile";
public static final String REQUEST_TOKEN_URL = "https://www.google.com/accounts/OAuthGetRequestToken";
public static final String ACCESS_TOKEN_URL = "https://www.google.com/accounts/OAuthGetAccessToken";
public static final String AUTHORIZE_URL = "https://www.google.com/accounts/OAuthAuthorizeToken";

I get connected to google asking to grant access for profile information. User grants the access, comes back to my application. Now I am trying to do this,

DefaultHttpClient httpClient = new DefaultHttpClient();
String strUrl = "https://www.googleapis.com/oauth2/v1/userinfo?alt=json";
HttpPost request = new HttpPost(strUrl);

to get the user's profile. But In response I get only

{

No data. I tried a lot to get the user profile. Plz do tell me where I am doing wrong. Any links, sample code will be appreciated. Thanks in advance.

1 Answer 1

1

Try using an HttpGet instead of HttpPost. The request needs to be a GET request for the resource, not a POST request.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.