Asp.net mvc 如何使用asp 5核心检索google访问令牌

Asp.net mvc 如何使用asp 5核心检索google访问令牌,asp.net-mvc,oauth,Asp.net Mvc,Oauth,嗨,我还没有找到检索访问令牌的方法 这是我的代码:(文件startup.cs) 我使用了asp 5中的mvc模板(Vs 2015) services.Configure(选项=> { options.ClientId=Configuration[“Authentication:Google:ClientId”]; options.ClientSecret=Configuration[“Authentication:Google:ClientSecret”]; options.AccessType

嗨,我还没有找到检索访问令牌的方法

这是我的代码:(文件startup.cs) 我使用了asp 5中的mvc模板(Vs 2015)

services.Configure(选项=>
{
options.ClientId=Configuration[“Authentication:Google:ClientId”];
options.ClientSecret=Configuration[“Authentication:Google:ClientSecret”];
options.AccessType=Configuration[“Authentication:Google:AccessType”];
options.Scope.Add(@)https://www.googleapis.com/auth/userinfo.email");
//options.CallbackPath
});
日志工作正常,我可以检索名称和其他有用信息,但不能检索令牌或刷新令牌

注意
GoogleAuthenticationOptions
is:Microsoft.AspNet.Authentication.Google.GoogleAuthenticationOptions与asp核心兼容,owin版本不兼容

谢谢


这些身份验证方案的定义功能之一是共享机密,您的应用程序和身份验证服务器必须知道这些机密。今天,在开发应用程序时,经常会意外地将其签入源代码管理,如果您使用诸如GitHub之类的公共源代码管理,允许任何人查看您签入的机密,这将是一个问题

试试这个:

 var configuration = new Configuration();
 configuration.AddJsonFile("config.json");
 configuration.AddEnvironmentVariables();

查看页面了解更多信息

这有帮助吗?所有人都可以帮助我,谢谢链接页面上的问题是在GoogleAuthenticationOptions中使用“provider”参数,这在Microsoft.AspNet.Authentication.Google.GoogleAuthenticationOptions中不可用,
 var configuration = new Configuration();
 configuration.AddJsonFile("config.json");
 configuration.AddEnvironmentVariables();