如何使用sharepoint访问office365上的成员信息

如何使用sharepoint访问office365上的成员信息,sharepoint,oauth,Sharepoint,Oauth,对不起,我的英语很差,只能用图表来描述我的问题 在下图中,如图所示,我想使用microsoftonline.com(作为A)登录,该帐户设置在我自己的服务器上(作为B)。在我的服务器(as B)中可以获取microsoftonline.com(as A)的帐户信息 如何实现 PS:当发生未经授权的错误时,我能够访问令牌社交api实现 寻求专家的帮助和指导。首先谢谢你 自己不断尝试之后,终于解决了这个问题,给点代码,方便别人的需要吧 使用csom开发 重要提示:rUri需要填写true,否则将发生

对不起,我的英语很差,只能用图表来描述我的问题

在下图中,如图所示,我想使用microsoftonline.com(作为A)登录,该帐户设置在我自己的服务器上(作为B)。在我的服务器(as B)中可以获取microsoftonline.com(as A)的帐户信息

如何实现

PS:当发生未经授权的错误时,我能够访问令牌社交api实现

寻求专家的帮助和指导。首先谢谢你


自己不断尝试之后,终于解决了这个问题,给点代码,方便别人的需要吧

使用csom开发

重要提示:rUri需要填写true,否则将发生错误

  string authCode = Request.QueryString["code"];
  string error = Request.QueryString["error"];
  if (authCode == "" || "access_denied" == error)
  {
      Response.Write("I'm sorry you do not have the right to access this site, please contact the system administrator authorization");
      Response.End();
  }
  Uri rUri = new Uri("You fill out an application API Redirect address as https://***/RedirectAccept.aspx");
  string o365Site = "You need an authorized user's site collection as https://***.sharepoint.com/";

  using (ClientContext context = TokenHelper.GetClientContextWithAuthorizationCode(
                                   o365Site, 
                                   "00000003-0000-0ff1-ce00-000000000000", 
                                   authCode, 
                                   TokenHelper.GetRealmFromTargetUrl(new Uri(o365Site)), 
                                   rUri)) {
    //
    Web web = context.Web;
    //          
    context.Load(web.CurrentUser);
    context.ExecuteQuery();

    Response.Write("context.Web.CurrentUser.LoginName" + " : " + context.Web.CurrentUser.LoginName + "<br/>");
    ......
string authCode=Request.QueryString[“code”];
string error=Request.QueryString[“error”];
if(authCode==“”| |“拒绝访问”==错误)
{
回复。写下(“很抱歉,您无权访问此网站,请联系系统管理员授权”);
Response.End();
}
Uri rUri=新Uri(“您将应用程序API重定向地址填写为https://***/RedirectAccept.aspx”);
string o365Site=“您需要一个授权用户的网站集,其格式为https://***.sharepoint.com/”;
使用(ClientContext context=TokenHelper.GetClientContextWithAuthorizationCode(
o365Site,
“00000003-0000-0ff1-ce00-000000000000”,
authCode,
TokenHelper.GetRealmFromTargetUrl(新Uri(o365Site)),
鲁里){
//
Web=context.Web;
//          
加载(web.CurrentUser);
context.ExecuteQuery();
Write(“context.Web.CurrentUser.LoginName”+”:“+context.Web.CurrentUser.LoginName+”
); ......