Google OAuth2: When and how to use refresh token

前端 未结 4 936
面向向阳花
面向向阳花 2021-01-07 01:46

I have an installed c# app with code working that gets the authorization code and exchanges it for an access token. I am storing off the refresh token. I know at some poin

4条回答
  •  [愿得一人]
    2021-01-07 02:25

    If someone still have Problems with refreshing the AccessToken, maybe this can help you finding a solution:

                Google.GData.Client.RequestSettings settings = new RequestSettings("");
                Google.GData.Client.OAuth2Parameters parameters = new OAuth2Parameters()
                {
                    ClientId = "",
                    ClientSecret = "",
                    AccessToken = "", //really necessary?
    
                    RedirectUri = "urn:ietf:wg:oauth:2.0:oob",
                    RefreshToken = "",
                    AccessType = "offline",
                    TokenType = "refresh",
                    Scope = "https://www.google.com/m8/feeds/" //Change to needed scopes, I used this for ContactAPI
                };
                try
                {
                    Google.GData.Client.OAuthUtil.RefreshAccessToken(parameters);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
    

提交回复
热议问题