【发布时间】:2015-06-12 11:27:46
【问题描述】:
这是所有感兴趣的人的完整来源: https://github.com/josephmcasey/me/blob/master/JosephMCasey/App_Start/Startup.Auth.cs
我正在使用带有 C# 的 ASP.Net 构建个人网站组合。目前我收到以下错误,我知道这些错误与我的 Startup.Auth.cs 类文件有关。
[ArgumentException: The 'ClientId' option must be provided.]
Microsoft.Owin.Security.Google.GoogleOAuth2AuthenticationMiddleware..ctor(OwinMiddleware next, IAppBuilder app, GoogleOAuth2AuthenticationOptions options) +280
lambda_method(Closure , OwinMiddleware , IAppBuilder , GoogleOAuth2AuthenticationOptions ) +83
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
如何在不手动将它们键入源代码的情况下从 azure 应用程序的设置中正确调用这些客户端密码字符串?
app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
{
ClientId = Environment.GetEnvironmentVariable("APPSETTING_Google-clientId"),
ClientSecret = Environment.GetEnvironmentVariable("APPSETTING_Google-clientSecret")
});
【问题讨论】:
-
云配置管理器
-
@MatíasFidemraizer 你不想正式回答吗?
-
@JosephCasey 现在我要去吃晚饭了……如果还没有人做的话,也许明天吧:(
-
请在this链接查看我的回答。
标签: c# asp.net azure environment-variables