How to generate access token using refresh token through google drive API?

前端 未结 8 1239
一个人的身影
一个人的身影 2020-12-04 14:33

I have completed steps of authorization and obtained access token and refresh token.

What should I do next to generate access token using refresh token that I have s

相关标签:
8条回答
  • 2020-12-04 15:00

    POST /oauth2/v4/token

    Host: www.googleapis.com

    Headers

    Content-length: 163

    content-type: application/x-www-form-urlencoded

    RequestBody

    client_secret=************&grant_type=refresh_token&refresh_token=sasasdsa1312dsfsdf&client_id=************

    0 讨论(0)
  • 2020-12-04 15:00

    Using ASP.Net Post call, this worked for me.

    StringBuilder getNewToken = new StringBuilder();
    getNewToken.Append("https://www.googleapis.com/oauth2/v4/token");                        
    HttpClient client = new HttpClient();
    client.BaseAddress = new Uri(getNewToken.ToString());
                        var values = new Dictionary<string, string>
                        {
                            { "client_id", <Your Client Id> },
                            { "client_secret", <Your Client Secret> },
                            { "refresh_token", <Your Saved Refresh Token> },
                            { "grant_type", "refresh_token"}
                        };
    
                        var content = new FormUrlEncodedContent(values);
                        var response = await client.PostAsync(getNewToken.ToString(), content);
    
    0 讨论(0)
提交回复
热议问题