谷歌更改默认的验证重定向 - C#(谷歌liblary) [英] Change Google default Auth Redirection - C# (Google liblary)
问题描述
我尝试这个code:的https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth#web_applications
I try this code: https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth#web_applications
我的code相同
但是!我需要更改此默认URL重定向。
现在是:REDIRECT_URI =的http:%2F%2Flocalhost:52674%2FAuthCallback%2FIndexAsync
But! I need change this default url redirection. Now is: redirect_uri=http:%2F%2Flocalhost:52674%2FAuthCallback%2FIndexAsync
我怎样才能改变这个网址?伙计们,请帮助。
How I can change this url? Guys please help.
感谢您
推荐答案
您可以继承的形式FlowMetadata并覆盖AuthCallback财产。您可以在下面的链接看看:
You can inherit form FlowMetadata and override the AuthCallback property. Take a look in the following link:
<一个href=\"https://$c$c.google.com/p/google-api-dotnet-client/source/browse/Src/GoogleApis.Auth.Mvc4/OAuth2/Mvc/FlowMetadata.cs?r=eb702f917c0e18fc960d077af132d0d83bcd6a88#49\" rel=\"nofollow\">https://$c$c.google.com/p/google-api-dotnet-client/source/browse/Src/GoogleApis.Auth.Mvc4/OAuth2/Mvc/FlowMetadata.cs?r=eb702f917c0e18fc960d077af132d0d83bcd6a88#49
但是,你将能够改变相对URL但不是绝对的。
BUT, You will be able to change the relative URL but not the absolute one.
如果你想使用一个完全不同的网址,您需要做的创建自己的授权codeMvcApp并改变其构造函数如下:
If you want to use a totally different URL, you will need to do create your own AuthorizationCodeMvcApp and change its constructor to the following:
public MyNewAuthorizationCodeMvcApp(Controller controller, FlowMetadata flowData)
: base(
flowData.Flow,
< YOUR URL HERE >,
controller.Request.Url.ToString())
{
this.controller = controller;
this.flowData = flowData;
}
然后你可以将其插入到你的流量,而不是默认的授权codeMvcApp(库的默认实现)。
Then you can plug it to your flow, instead of the default AuthorizationCodeMvcApp (the default implementation of the library).
这篇关于谷歌更改默认的验证重定向 - C#(谷歌liblary)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!