Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net Sharepoint Online上禁止WebRequest_Asp.net_Sharepoint_Httpwebrequest_Http Status Code 403_Webrequest - Fatal编程技术网

Asp.net Sharepoint Online上禁止WebRequest

Asp.net Sharepoint Online上禁止WebRequest,asp.net,sharepoint,httpwebrequest,http-status-code-403,webrequest,Asp.net,Sharepoint,Httpwebrequest,Http Status Code 403,Webrequest,我需要使用访问令牌创建对SharePoint Online中特定页面的web请求,以获取某些标题信息,但我一直得到403,我不知道为什么。在处理了更多的访问请求之后,我使用clientContext只能得到403个,使用Postman只能得到401个 我可以从我的应用程序中的grah api和使用access token的postman获得响应,但问题是我需要执行一个web请求来获取真正的网页标题,如SpRequestDuration和spiislatence 我已经按照步骤创建了Azure广告

我需要使用访问令牌创建对SharePoint Online中特定页面的web请求,以获取某些标题信息,但我一直得到403,我不知道为什么。在处理了更多的访问请求之后,我使用clientContext只能得到403个,使用Postman只能得到401个

我可以从我的应用程序中的grah api和使用access token的postman获得响应,但问题是我需要执行一个web请求来获取真正的网页标题,如SpRequestDuration和spiislatence

我已经按照步骤创建了Azure广告和应用程序。 我请求用户登录以获取我的应用程序的身份验证代码

loginScopes = [
'User.Read.All',
'Directory.Read.All',
'Group.Read.All',
'Sites.Read.All',
'Reports.Read.All' 
'offline_access',
'https://www.sharepoint.com/AllSites.FullControl'
];

const encodedScopes = encodeURIComponent(loginScopes.join(' '));
const encodedRedirectUri = encodeURIComponent(redirectUri);
let url = `https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?
response_type=code&
client_id=${clientId}
&redirect_uri=${encodedRedirectUri}
&scope=${encodedScopes}
&prompt=select_account`;
在返回身份验证代码后,我创建了具有权限的SecretentialClientApplication:“”和我的应用程序clientId、secret、redirect等。使用新创建的SecretentialClientApplication,我以作用域“{tenantUrl}/AllSites.FullControl”静默方式获取令牌,并使用其他作用域获取另一个令牌

现在有了access token,我成功地创建了ClientContext,它从sharepoint站点检索数据,我可以轻松地发出graph API请求,一切都会好起来的。但问题在于创建对特定站点的WebRequest(例如{tenantur}/SitePages/Forms/ByAuthor.aspx)

使用sharepoint online

string siteUrl = ConfigurationManager.AppSettings["siteURL"];
SecureString passWord = new SecureString();
string pass = ConfigurationManager.AppSettings["userPassword"];
string user = ConfigurationManager.AppSettings["userName"];
foreach (char c in pass.ToCharArray()) passWord.AppendChar(c);
ClientContext clientContext = new ClientContext(siteUrl);
clientContext.Credentials = new SharePointOnlineCredentials(user, passWord);
return clientContext;
没有

clientContext.ExecutingWebRequest
clientContext.ExecutingWebRequest