How to get access token for google oauth?

前端 未结 5 1788
离开以前
离开以前 2021-02-05 21:30

I am using C# (ASP.NET). I want to use Google OAuth for accessing the user profile detail in my app. I successfully got the authorization code but having a problem in getting th

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-05 21:57

    My code is working, I have done mistakes in above two lines. It should be like this

    byte[] buffer = Encoding.ASCII.GetBytes("code=" + code + "&client_id=xxx&client_secret=xxx&redirect_uri=xxxx&grant_type=authorization_code");
    HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://accounts.google.com/o/oauth2/token");
    

    Remaining code is correct.

提交回复
热议问题