Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to conect to Sharepoint(acquire_authentication_cookie error if federated) #210

Closed
liuliqiu opened this issue Jun 17, 2020 · 3 comments
Labels

Comments

@liuliqiu
Copy link
Contributor

liuliqiu commented Jun 17, 2020

I have been been trying connect with some special Sharepoint account use the 2.1.9 version release.

from office365.runtime.auth.authentication_context import AuthenticationContext
ctx_auth = AuthenticationContext(url)
ctx_auth.acquire_token_for_user(account, password)

It fails with log

[17/Jun/2020 05:20:19] DEBUG [none] [urllib3.connectionpool:_make_request:428] https://somehost.sharepoint.com:443 "HEAD /_vti_bin/idcrl.svc HTTP/1.1" 401 0
[17/Jun/2020 05:20:19] ERROR [none] [office365.runtime.auth.saml_token_provider.SamlTokenProvider.acquire_authentication_cookie:acquire_authentication_cookie:214] An error occurred while retrieving auth cookies from https://somehost.sharepoint.com/_vti_bin/idcrl.svc

Then i try the account with PowerShell.

$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$SitePassword = ConvertTo-SecureString $SitePassword -AsPlainText -Force
$Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($SiteUser,$SitePassword)
$Context.Credentials = $Creds
$web = $Context.Web
$Context.Load($web)
$Context.ExecuteQuery()

And i find the request like

GET https://somehost.sharepoint.com/_vti_bin/idcrl.svc/ HTTP/1.1
Authorization: BPOSIDCRL t=EwDoAk6hBwA...gC&p=
X-IDCRL_ACCEPTED: t
Host: somehost.sharepoint.com

It's use GET not HEAD, and url endswith /, and header not contains "Content-Type".
so i modify the python source code, and it works.
and i find a reply on https://sharepoint.stackexchange.com/questions/222917/rest-authentication-to-online-sharepoint use GET.

liuliqiu added a commit to liuliqiu/Office365-REST-Python-Client that referenced this issue Jun 17, 2020
@liuliqiu
Copy link
Contributor Author

@vgrem
Copy link
Owner

vgrem commented Jun 17, 2020

Greetings @liuliqiu,

thank you for tracking it down, looks promising.

Will confirm and and commit the proposed adjustments in the next release.

Cheers,
Vadim

@vgrem
Copy link
Owner

vgrem commented Jun 18, 2020

The change has been applied in the latest commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants