我正在创建一个将使用CSOM连接到SharePoint Online的守护程序应用程序。我的应用程序将运行在互联网代理之后的企业环境中。我正在使用标准的SharePoint插件模型,并提供了使用Microsoft.IdentityModel.Extensions.dll的TokenHelper和SharePointContext类。如何强制Microsoft.IdentityModel.S2S.Protocols.OAuth2.OAuth2S2SClient.Issue使用Web代理?
我已经操纵TokenHelper在两个地方使用代理:GetRealmFromTargetUrl中的WebRequest和AcsMetadataParser中的WebClient。
但它不起作用,因为在我看来,DLL使用另一个Web请求。下面是触发异常的执行的StackTraces:
Exception Message: Token request failed.
Stack Trace:
at Microsoft.IdentityModel.S2S.Protocols.OAuth2.OAuth2S2SClient.Issue(String securityTokenServiceUrl, OAuth2AccessTokenRequest oauth2Request)
at ScriptTask_d38d98a4cb054097ac7c2ece4802bf9a.spo.TokenHelper.GetAppOnlyAccessToken(String targetPrincipalName, String targetHost, String targetRealm)
at ScriptTask_d38d98a4cb054097ac7c2ece4802bf9a.ScriptMain.Main()
Inner Exception Message: Unable to connect to the remote server
Inner Stack Trace:
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at Microsoft.IdentityModel.S2S.Protocols.OAuth2.OAuth2WebRequest.GetResponse()
at Microsoft.IdentityModel.S2S.Protocols.OAuth2.OAuth2S2SClient.Issue(String securityTokenServiceUrl, OAuth2AccessTokenRequest oauth2Request)
我不知道是否有解决方法?
什么是webProxy和InternetProxy。以及如何使用这种方法?你能否认罪?我有相同的问题 – SigarDave
'var webProxy = new System.Net.WebProxy {Address = new Uri(InternetProxy)};' 和InternetProxy是您的代理的地址,例如'http://proxy.domain.com: 8080' – prot