【发布时间】:2016-05-19 13:35:07
【问题描述】:
谁能解释为什么从 SharePoint Online 使用 OpenIdConnectAuthentication 对 Azure 加载项的第一次调用具有 URL:
https://login.microsoftonline.com/tenantGuid/oauth2/authorize?client_id=xxx&response_mode=form_post&response_type=code+id_token&scope=openid+profile&state=OpenIdConnect.AuthenticationProperties%...
第二个调用有 URL
https://yyy.sharepoint.com/_layouts/15/online/cloudappsredirect.aspx?addintype=FileHandler&usemds=false&appurl=https%...¶ms
是否有可能从第一次调用中获取 Url2 的参数?
编辑
从一位朋友和GPX file handler 代码那里得到了一个提示。
在 OpenIdConnectAuthenticationOptions 的通知中,您可以指定 RedirectToIdentityProvider 函数。在这里,您可以将 Query 字符串的所有必要信息保存在 cookie 中,因为 Session 在这里不起作用。
RedirectToIdentityProvider = (context) =>
{
var directoryAndFilenameReferrer = System.Web.HttpContext.Current.Request.UrlReferrer.Query.Split('&').Where(x => x.StartsWith("itemurl", StringComparison.Ordinal)).FirstOrDefault();
var directoryAndFilename = System.Web.HttpUtility.UrlDecode(directoryAndFilenameReferrer).Split('/');
context.Response.Cookies.Append("cookie_Filename", directoryAndFilename[directoryAndFilename.Length - 1]);
return Task.FromResult(0);
}
之后别忘了删除 cookie。
【问题讨论】:
标签: office365 openid-connect office365api microsoft-graph-api