2

我成功地使用 GoogleAuthorizationCodeFlow 来获取和存储凭据以访问 Google Calendar API。我想使用include_granted_scopes=true查询参数进行增量授权

我搜索了很长时间,但无法弄清楚如何包含include_granted_scopes参数。有没有办法这样做?

4

2 回答 2

1

首先获取您的授权网址

GoogleAuthorizationCodeRequestUrl authUrl = googleAuthorizationCodeFlow.newAuthorizationUrl();

授权 url 只是 a 的一个实例GenericUrl,因此您可以使用GenericUrl.set(key, value)设置任意查询参数。

authUrl.set("include_granted_scopes", true);
于 2018-12-21T19:39:16.040 回答
0

尝试以下操作:

var googleOAuthOptions = 
    new GoogleOAuth2AuthenticationOptions()
    {
        ClientId = "...",
        ClientSecret = "...",

        Provider = new GoogleOAuth2AuthenticationProvider
                    {
                        OnApplyRedirect = context =>
                        {
                            var redirect = context.RedirectUri;
                            redirect += "&include_granted_scopes=true";
                            context.Response.Redirect(redirect);

                        }
                    }
    };

googleOAuthOptions.Scope.Add(...);

app.UseGoogleAuthentication(googleOAuthOptions);
于 2015-02-14T05:21:44.227 回答