1

How to fetch user information in MVC5 from google API through access_token which token provided by the mobile end into web API? [Used Code][1]: https://i.sstatic.net/D2hfW.png

HttpClient client = new HttpClient();
var urlProfile ="https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + model.Auth;
client.CancelPendingRequests();
HttpResponseMessage output = client.GetAsync(urlProfile).Result;
if (output.IsSuccessStatusCode)
{
    string outputData = output.Content.ReadAsStringAsync().Result;
}

Getting Error: If I am using above code to fetch user information by access_token

{
  "error": {
    "code": 401,
    "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED"
  }
}

1 Answer 1

1

Solve this issue: I have used another API to fetch user info from google. https://oauth2.googleapis.com/tokeninfo?id_token=Auth

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.