我正在构建一个使用cookie身份验证作为主要身份验证方法的MVC 5 Web应用程序.
我们的申请流程如下:
问题是,实现访问令牌验证,到期和续订的最佳位置是什么.如果有人能引导我走向正确的方向,我真的很感激.
var googleCreds = new GoogleOAuth2AuthenticationOptions
{
ClientId = "833250754551-qg564a5g29f0l37q0egqimcoklpjf6dj.apps.googleusercontent.com",
ClientSecret = "YpY_u07KQU4kjhPWH5vuiMzz"
Provider = new Microsoft.Owin.Security.Google.GoogleOAuth2AuthenticationProvider
{
OnApplyRedirect = context =>
{
var queryString = HttpContext.Current.Request.QueryString.ToString();
var queryParms = HttpUtility.ParseQueryString(queryString);
string redirect = context.RedirectUri;
redirect += "&access_type=offline";
redirect += "&approval_prompt=force";
redirect += "&include_granted_scopes=true";
var uri = new Uri(redirect);
if ((!string.IsNullOrEmpty(queryParms.Get("scope"))))
{
var scope = queryParms.Get("scope");
var redirectQueryString = HttpUtility.ParseQueryString(uri.Query);
switch (scope)
{
case "GooglePlus":
redirectQueryString.Set("scope", "https://www.googleapis.com/auth/plus.login");
break; …Run Code Online (Sandbox Code Playgroud)