我尝试使用此代码通过Google.Apis.Auth.OAuth2库获取应用程序的Google刷新令牌 . 当我在 localhost , it is worked perfect 上使用它时,但是当我在 Azure site it will be throw System.AggregateException 下使用它时,Access被拒绝了InnerException .
UserCredential credential =
GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets()
{
ClientId = "<client_id>",
ClientSecret = "<client_secret>"
},
new string[] { },
Environment.UserName,
CancellationToken.None,
null
).Result;
string refreshToken = credential.Token.RefreshToken;
内在的例外是:
InnerException消息:System.Net.HttpListener.SetupV2Config()在System.Net.HttpListener.Start()处的Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.d__6.MoveNext()中拒绝访问 - 堆栈跟踪结束来自抛出异常的先前位置---在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)处于System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务),位于Google.Apis.Auth.OAuth2.AuthorizationCodeInstalledApp.d__8 .MoveNext()---抛出异常的前一个位置的堆栈跟踪结束---在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)的System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)处Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__4.MoveNext()---从抛出异常的上一个位置开始的堆栈跟踪结束---在系统的System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__1.MoveNext()上的.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)
有没有其他方法来获取刷新令牌?
谢谢!
1 回答
您是否已将Azure URI配置为Google控制台API管理器中的授权?