JonathanHolvey / sharepy

Simple SharePoint authentication for Python
GNU General Public License v3.0
175 stars 52 forks source link

AADSTS50126: Error validating credentials due to invalid username or password #42

Open rajmetti opened 4 years ago

rajmetti commented 4 years ago

after proving username , sharepy stuck at password only enter key is working

JonathanHolvey commented 4 years ago

The password will not be shown when you type it. This is typical of command line applications. You can type it blind, or pass it in as a parameter:

import sharepy
sharepy.connect('sharepoint.example.com', 'user@example.com', password='1csAean6ZtwahpF3')
rajmetti commented 4 years ago

okay ill try and report back

rajmetti commented 4 years ago

@JonathanHolvey i tried like you mentioned and it is giving the error like "AADSTS50126: Error validating credentials due to invalid username or password"

JonathanHolvey commented 4 years ago

Can you try to connect using the following scenarios and post any error messages you get?

rajmetti commented 4 years ago

i've tried with incorrect credentials and here is the error "AADSTS50034: The user account {EmailHidden} does not exist in the hp.com directory. To sign into this application, the account must be added to the directory"

rajmetti commented 4 years ago

when i tried with my friends credentials the error is "AADSTS90023: Invalid STS request"

JonathanHolvey commented 4 years ago

That's weird. Are you connecting to the same SharePoint site with the two accounts?

rajmetti commented 4 years ago

@JonathanHolvey Yes, my sharepoint site url is like "https://company_name.sharepoint.com"

JonathanHolvey commented 4 years ago

Can you visit the URL below, replacing <username> with the username you use to log in, then post the XML response here? Be sure to remove any sensitive data from the XML.

https://login.microsoftonline.com/GetUserRealm.srf?login=&xml=1

rajmetti commented 4 years ago

@JonathanHolvey sorry for the late report , ive been on holidays. the above is the xml ive got and removed some sensitive info

rajmetti commented 4 years ago
> <RealmInfo Success="true">
> <State>3</State>
> <UserState>2</UserState>
> <Login>user.name@company.com</Login>
> <NameSpaceType>Federated</NameSpaceType>
> <DomainName>company.com</DomainName>
> <FederationGlobalVersion>-1</FederationGlobalVersion>
> <AuthURL>
> https://login.external.company.com/idp/prp.wsf?username=user.name%40company.com&wa=wsignin1.0&wtrealm=urn%3afederation%3aMicrosoftOnline&wctx=
> </AuthURL>
> <IsFederatedNS>true</IsFederatedNS>
> <STSAuthURL>https://login.external.hp.com/idp/sts.wst</STSAuthURL>
> <FederationTier>0</FederationTier>
> <FederationBrandName>HP Inc.</FederationBrandName>
> <AllowFedUsersWLIDSignIn>false</AllowFedUsersWLIDSignIn>
> <Certificate>
> TUlJRkx6Q0NCQmVnQXdJQkFnSVJBT0x6bklsUUFxTzBBQUFBQUZEZ0FQVXdEUVlKS29aSWh2Y05BUUVMQlFBd2dib3hDekFKQmdOVkJBWVRBbFZUTVJZd0ZBWURWUVFLRXcxRmJuUnlkWE4wTENCSmJtTXVNU2d3SmdZRFZRUUxFeDlUWldVZ2QzZDNMbVZ1ZEhKMWMzUXVibVYwTDJ4bFoyRnNMWFJsY20xek1Ua3dOd1lEVlFRTEV6QW9ZeWtnTWpBeE1pQkZiblJ5ZFhOMExDQkpibU11SUMwZ1ptOXlJR0YxZEdodmNtbDZaV1FnZFhObElHOXViSGt4TGpBc0JnTlZCQU1USlVWdWRISjFjM1FnUTJWeWRHbG1hV05oZEdsdmJpQkJkWFJvYjNKcGRIa2dMU0JNTVVzd0hoY05NVGd3TVRJMU1ESTBNVEk1V2hjTk1qQXdNVEkxTURNeE1USTRXakJkTVFzd0NRWURWUVFHRXdKVlV6RU9NQXdHQTFVRUNCTUZWR1Y0WVhNeER6QU5CZ05WQkFjVEJrRjFjM1JwYmpFUE1BMEdBMVVFQ2hNR1NGQWdTVzVqTVJ3d0dnWURWUVFERXhOc2IyZHBiaTF3Y204dWFYUXVhSEF1WTI5dE1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBdEFuNnZNZHJwQUl2eUViS2c4bFdTWVo3M1g5SjVvK1AvbXdITC9vSnNIeEJRRm5sQUdnMGdoVmtwVDU4cFB2QUQ5VjRDSWNiY0J2b29rVXlmNXM3VG9KZHozdFFaQzBSUHZEc3V6THo3S1FuNGpMREgyamkzVEVjdFVHSnBGSm5iYStXbjlxUGJVUy9kZEdmbms4cm5BcGhSYVFUM0RodU8weG8yQkV0elo4NFFsNzNRZ2pWQzhBRmJEbW5NczJTZzRZYk5DWXk2NE41RWl2dVRheEhyV09sc0tycXRXaXRxOGR1aXlTVG43d3NKOVA3Q3IvKzJ3OUtlNThGakJ2TStLV0RGQ1hKeXFYbmIvbGw1L09wdHdLOWwwMTJUOG5pOWFmZjh4MFJySFZFYmdjMnhwdUowRUc3K1J0bThjYVh5eFNZTlp6TTRVK0tZSkdKZFJmOWxRSURBUUFCbzRJQmlqQ0NBWVl3RGdZRFZSMFBBUUgvQkFRREFnV2dNQjBHQTFVZEpRUVdNQlFHQ0NzR0FRVUZCd01CQmdnckJnRUZCUWNEQWpBekJnTlZIUjhFTERBcU1DaWdKcUFraGlKb2RIUndPaTh2WTNKc0xtVnVkSEoxYzNRdWJtVjBMMnhsZG1Wc01Xc3VZM0pzTUVzR0ExVWRJQVJFTUVJd05nWUtZSVpJQVliNmJBb0JCVEFvTUNZR0NDc0dBUVVGQndJQkZocG9kSFJ3T2k4dmQzZDNMbVZ1ZEhKMWMzUXVibVYwTDNKd1lUQUlCZ1puZ1F3QkFnSXdhQVlJS3dZQkJRVUhBUUVFWERCYU1DTUdDQ3NHQVFVRkJ6QUJoaGRvZEhSd09pOHZiMk56Y0M1bGJuUnlkWE4wTG01bGREQXpCZ2dyQmdFRkJRY3dBb1luYUhSMGNEb3ZMMkZwWVM1bGJuUnlkWE4wTG01bGRDOXNNV3N0WTJoaGFXNHlOVFl1WTJWeU1CNEdBMVVkRVFRWE1CV0NFMnh2WjJsdUxYQnlieTVwZEM1b2NDNWpiMjB3SHdZRFZSMGpCQmd3Rm9BVWdxSndkTjI4VXovUGU5VDN6WCtuWU1ZS1RMOHdIUVlEVlIwT0JCWUVGTFkxTVl3YXA5WTRzOHFqYzFRdlFLdVI2OEI5TUFrR0ExVWRFd1FDTUFBd0RRWUpLb1pJaHZjTkFRRUxCUUFEZ2dFQkFGZWdkcEV4MldKTDZWa0lST2QrWGg3ekZvRFZhYktpQVd1NVBhV3BPV2Ryc1NDWGhic1Y5RjBwSmFPS1hqQ3Y3UGZSZDhMWmFrRGlGSzVSMnprSk45cEhPTkpVenhxSjFXalZmVElZQ2lUOVYwOUw4R05icUF2bTlULzVKVUx4NVZ0S2daT1oxZWRpMmFtVEdWN3BVUmYrWjdmNkpFYWlJWnZOR0ZKNXUvR3FRTThCamhLWWE0OGZPM2ZTK1lDMGJDU3VmSHBNOXp0d3Uxb1RsV25md3V5c1Z0STd6SUI1M2xRTzBlNVVnNUVFTXE4ME9MQ0VNbVZueU0yWWxGZ0dnRXVFWHkyT2ZBZjJGdG1lQVdUQXA0QXZvaG03NjJ1V0FJWHdPNjJrS3g0VmhPRzhZK2pGa25ScW41VEk0ZXozVlpOd3c5ZnE4QkV1SnlsY1NZUlBr
> </Certificate>
> <MEXURL>
> https://login.external.hp.com/pf/sts_mex.ping?PartnerSpId=urn:federation:MicrosoftOnline
> </MEXURL>
> <PreferredProtocol>1</PreferredProtocol>
> <EDUDomainFlags>0</EDUDomainFlags>
> <CloudInstanceName>microsoftonline.com</CloudInstanceName>
> <CloudInstanceIssuerUri>urn:federation:MicrosoftOnline</CloudInstanceIssuerUri>
> 
> > </RealmInfo>``
JonathanHolvey commented 4 years ago

Thanks for that.

The <NameSpaceType>Federated</NameSpaceType> node indicates that your SharePoint site uses a type of authentication that isn't supported by the current version of SharePy. Fortunately, an upcoming v2 release has additional support.

Can you please try connecting using the release-2.0.0-beta branch, and report back with any issues?

https://github.com/JonathanHolvey/sharepy/tree/release-2.0.0-beta

rajmetti commented 4 years ago

okay let me try and ill post the result .

rajmetti commented 4 years ago

i tried this code

import sharepy

auth = sharepy.auth.SharePointOnline(username="user@example.com")
auth.login_url = "https://login.microsoftonline.de/extSES.srf"
s = sharepy.connect("example.sharepoint.com", auth)

the output is :

Traceback (most recent call last):

  File "c:/Users/temp/OneDrive - company/Desktop/py.py", line 5, in <module>
    s = sharepy.connect("company.sharepoint.com", auth)
  File "C:\Users\temp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\sharepy\session.py", line 14, in connect
    autoauth = auth.detect(username=username, password=password)
  File "C:\Users\temp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\sharepy\auth\detect.py", line 19, in detect
    realm = et.fromstring(requests.get(url.format(escape(username))).text)
  File "C:\Users\temp\AppData\Local\Programs\Python\Python38-32\lib\xml\sax\saxutils.py", line 27, in escape
    data = data.replace("&", "&amp;")
AttributeError: 'SharePointOnline' object has no attribute 'replace'
JonathanHolvey commented 4 years ago

Since you're using a site with federated authentication, you should be able to do this, and SharePy will automatically detect the login URL:

import sharepy
s = sharepy.connect('company.sharepoint.com', username=username, password=password)

Note that what you did was override the automatic auth type detection by creating a SharePointOnline auth object, which is the type used by SharePoint v1. Also, there's a mistake in the readme which mislead you. It's not the connect function that can be passed the auth object (that only accepts credentials), but the session constructor. You could have done this instead:


import sharepy
auth = sharepy.auth.SharePointADFS(username=username, password=password)
auth.login_url = "https://login.microsoftonline.de/extSES.srf"
s = sharepy.SharePointSession("company.sharepoint.com", auth)
rajmetti commented 4 years ago

okay @JonathanHolvey ill try this one and let you know the output

rajmetti commented 4 years ago

This is the output, seems issue with authorization

Traceback (most recent call last):
  File "C:\Users\temp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\sharepy\auth\adfs.py", line 69, in _get_token
    root = et.fromstring(response.text)
  File "C:\Users\temp\AppData\Local\Programs\Python\Python38-32\lib\xml\etree\ElementTree.py", line 1321, in XML
    return parser.close()
xml.etree.ElementTree.ParseError: no element found: line 1, column 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:/Users/temp/OneDrive - company/Desktop/pyhton_sp6.py", line 5, in <module>
    s = sharepy.SharePointSession("company.sharepoint.com", auth)
  File "C:\Users\temp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\sharepy\session.py", line 61, in __init__
    self.auth.login(self.site)
  File "C:\Users\temp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\sharepy\auth\adfs.py", line 27, in login
    self._get_token()
  File "C:\Users\temp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\sharepy\auth\adfs.py", line 71, in _get_token
    raise errors.AuthError("Token request failed. Invalid server response")
sharepy.errors.AuthError: Token request failed. Invalid server response
JonathanHolvey commented 4 years ago

You should use the first snippet I posted, as it will determine both the auth type and the login URL for you:

import sharepy
s = sharepy.connect('company.sharepoint.com', username=username, password=password)

The second snippet I posted was just to clarify the mistake in the readme, and show how to change the login URL if you need to. I tried the second snippet with my credentials and got exactly the same error as you did.

rajmetti commented 4 years ago
Traceback (most recent call last):
  File "C:\lib\site-packages\sharepy\auth\adfs.py", line 91, in _get_token
    token = root.find(".//wsse:BinarySecurityToken", ns).text
AttributeError: 'NoneType' object has no attribute 'text'``
rajmetti commented 4 years ago

this is the output it showing

JonathanHolvey commented 4 years ago

Can you add print(response.text) above line 91 in adfs.py? The full path to that file on your system is shown in the error message you posted.

This will let us see the response XML so we can try to work out what's going on. Again, make sure you remove any sensitive data before posting.

rajmetti commented 4 years ago

okay @JonathanHolvey , ill let you know the result

rajmetti commented 4 years ago
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-xxxxxx-wss-wssecurity-secext-1.0.xsd" xmlns:wst="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-xxxxxxx-wss-wssecurity-utility-1.0.xsd">
  <S:Header>
    <psf:pp xmlns:psf="http://schemas.microsoft.com/Passport/SoapServices/SOAPFault">
      <psf:serverVersion>1</psf:serverVersion>
      <psf:authstate>0x80048800</psf:authstate>
      <psf:reqstatus>0x80045c17</psf:reqstatus>
      <psf:serverInfo ServerTime="2020-01-23T13:14:01.5177509Z">PROD-AMS2-001.ProdSlices rid:XXXXXXXXX</psf:serverInfo>
    </psf:pp>
  </S:Header>
  <S:Body>
    <S:Fault>
      <S:Code>
        <S:Value>S:Sender</S:Value>
        <S:Subcode>
          <S:Value>wst:FailedAuthentication</S:Value>
        </S:Subcode>
      </S:Code>
      <S:Reason>
        <S:Text xml:lang="en-US">Authentication Failure</S:Text>
      </S:Reason>
      <S:Detail>
        <psf:error xmlns:psf="http://schemas.microsoft.com/Passport/SoapServices/SOAPFault">
          <psf:value>0x80045C17</psf:value>
          <psf:internalerror>
            <psf:code>0x80045C17</psf:code>
            <psf:text>AADSTS500069: The element with ID '_xxxxxxxxxxxxxxxxxxxxxxxx9dee' was either unsigned or the signature was invalid.</psf:text>
          </psf:internalerror>
        </psf:error>
      </S:Detail>
    </S:Fault>
  </S:Body>
</S:Envelope>
rajmetti commented 4 years ago

@JonathanHolvey any other way

JonathanHolvey commented 4 years ago

Sorry, I haven't had a chance to look into this further.

Are you able to confirm whether the site you're connecting is using ADFS authentication?

rajmetti commented 4 years ago

Ill ask my admin, But when i was connecting through browser it is giving coookies rtfa and fedauth when i pass those cokkies in header inside the code im able to download the files

rajmetti commented 4 years ago

@JonathanHolvey No ADFS

rajmetti commented 4 years ago

Thanks for the support @JonathanHolvey . issue is not resolved, i think my share point using some other authentication system.

JonathanHolvey commented 4 years ago

Is the site you're connecting to hosted by Microsoft as SharePoint Online, or is it an on-premises site?

rajmetti commented 4 years ago

Yes it is on-premises site and hosted by Microsoft as SharePoint Online

JonathanHolvey commented 4 years ago

I'm confused. On-premises means hosted by you on a physical server you control.

SharePy isn't intended to work with on-premises sites. It may work in some circumstances, but I've never tested it, nor heard of anyone who got it working.

Bliss161 commented 4 years ago

AADSTS500069: The element with ID '_xxxxxxxxxxxxxxxxxxxxxxxx9dee' was either unsigned or the signature was invalid.

Seems to be an issue with the xml library used (maybe specifically when on windows), for me it is modifying the xml content in such a way that the server rejects the request.

This is the code in question (adfs.py):

        # Extract token from returned XML
        assertion = root.find(".//saml:Assertion", ns)
        if assertion is None or root.find(".//S:Fault", ns) is not None:
            raise errors.AuthError("{}: {}".format(root.find(".//S:Text", ns).text,
                                   root.find(".//psf:text", ns).text).strip().strip("."))
        assertion.set("xs", ns["xs"])  # Add namespace for assertion values
        saml_assertion = et.tostring(assertion, encoding='unicode')

Using this regex instead of the code above worked for me, but this should be refined:

        import re
        saml_assertion = re.search('<saml:Assertion.*</saml:Assertion>', response.text, flags=re.IGNORECASE|re.DOTALL).group(0)
rajmetti commented 4 years ago

@JonathanHolvey okay,

JonathanHolvey commented 4 years ago

@bliss161 can you go into a bit more detail about how the XML is being modified. I have made changes to the way the XML is being parsed, but I don't have an ADFS site to test with

rbthomp commented 4 years ago

Just want to add, tried @Bliss161 fix for AFDS and I was able to connect.https://github.com/JonathanHolvey/sharepy/issues/42#issuecomment-586562638

Bliss161 commented 4 years ago

Sorry for the super late reply. I'm assuming its KeyInfo becoming ds:KeyInfo.

Current method

<saml:Assertion xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ns1="http://schemas.xmlsoap.org/ws/2009/09/identity/claims" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" AssertionID="_{guid}" IssueInstant="2020-06-02T11:16:03.724Z" Issuer="http://{site}/adfs/services/trust/" MajorVersion="1" MinorVersion="1" xs="http://www.w3.org/2001/XMLSchema">
    <saml:Conditions NotBefore="{timestamp}" NotOnOrAfter="{timestamp}">
        <saml:AudienceRestrictionCondition>
            <saml:Audience>urn:federation:MicrosoftOnline</saml:Audience>
        </saml:AudienceRestrictionCondition>
    </saml:Conditions>
    <saml:AttributeStatement>
        <saml:Subject>
            <saml:NameIdentifier Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">{id}</saml:NameIdentifier>
            <saml:SubjectConfirmation>
                <saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</saml:ConfirmationMethod>
            </saml:SubjectConfirmation>
        </saml:Subject>
        <saml:Attribute AttributeName="UPN" AttributeNamespace="http://schemas.xmlsoap.org/claims">
            <saml:AttributeValue>{user}@{site}</saml:AttributeValue>
        </saml:Attribute>
        <saml:Attribute AttributeName="ImmutableID" AttributeNamespace="http://schemas.microsoft.com/LiveID/Federation/2008/05">
            <saml:AttributeValue>{id}</saml:AttributeValue>
        </saml:Attribute>
        <saml:Attribute AttributeName="insidecorporatenetwork" AttributeNamespace="http://schemas.microsoft.com/ws/2012/01" ns1:OriginalIssuer="CLIENT CONTEXT">
            <saml:AttributeValue xsi:type="tn:boolean">true</saml:AttributeValue>
        </saml:Attribute>
    </saml:AttributeStatement>
    <saml:AuthenticationStatement AuthenticationInstant="{timestamp}" AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:password">
        <saml:Subject>
            <saml:NameIdentifier Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">{id}</saml:NameIdentifier>
            <saml:SubjectConfirmation>
                <saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</saml:ConfirmationMethod>
            </saml:SubjectConfirmation>
        </saml:Subject>
    </saml:AuthenticationStatement>
    <ds:Signature>
        <ds:SignedInfo>
            <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
            <ds:Reference URI="#_{guid}">
                <ds:Transforms>
                    <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
                    <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
                </ds:Transforms>
                <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
                <ds:DigestValue>{digest}</ds:DigestValue>
            </ds:Reference>
        </ds:SignedInfo>
        <ds:SignatureValue>{signature}</ds:SignatureValue>
        <ds:KeyInfo>
            <ds:X509Data>
                <ds:X509Certificate>{cert}</ds:X509Certificate>
            </ds:X509Data>
        </ds:KeyInfo>
    </ds:Signature>
</saml:Assertion>

Using Regex

<saml:Assertion MajorVersion="1" MinorVersion="1" AssertionID="_{guid}" Issuer="http://{site}/adfs/services/trust/" IssueInstant="2020-06-02T11:16:03.724Z" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion">
    <saml:Conditions NotBefore="{timestamp}" NotOnOrAfter="{timestamp}">
        <saml:AudienceRestrictionCondition>
            <saml:Audience>urn:federation:MicrosoftOnline</saml:Audience>
        </saml:AudienceRestrictionCondition>
    </saml:Conditions>
    <saml:AttributeStatement>
        <saml:Subject>
            <saml:NameIdentifier Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">{id}</saml:NameIdentifier>
            <saml:SubjectConfirmation>
                <saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</saml:ConfirmationMethod>
            </saml:SubjectConfirmation>
        </saml:Subject>
        <saml:Attribute AttributeName="UPN" AttributeNamespace="http://schemas.xmlsoap.org/claims">
            <saml:AttributeValue>{user}@{site}</saml:AttributeValue>
        </saml:Attribute>
        <saml:Attribute AttributeName="ImmutableID" AttributeNamespace="http://schemas.microsoft.com/LiveID/Federation/2008/05">
            <saml:AttributeValue>{id}</saml:AttributeValue>
        </saml:Attribute>
        <saml:Attribute AttributeName="insidecorporatenetwork" AttributeNamespace="http://schemas.microsoft.com/ws/2012/01" a:OriginalIssuer="CLIENT CONTEXT" xmlns:a="http://schemas.xmlsoap.org/ws/2009/09/identity/claims">
            <saml:AttributeValue b:type="tn:boolean" xmlns:b="http://www.w3.org/2001/XMLSchema-instance" xmlns:tn="http://www.w3.org/2001/XMLSchema">true</saml:AttributeValue>
        </saml:Attribute>
    </saml:AttributeStatement>
    <saml:AuthenticationStatement AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:password" AuthenticationInstant="{timestamp}">
        <saml:Subject>
            <saml:NameIdentifier Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">{id}</saml:NameIdentifier>
            <saml:SubjectConfirmation>
                <saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</saml:ConfirmationMethod>
            </saml:SubjectConfirmation>
        </saml:Subject>
    </saml:AuthenticationStatement>
    <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <ds:SignedInfo>
            <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
            <ds:Reference URI="#_{guid}">
                <ds:Transforms>
                    <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
                    <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
                </ds:Transforms>
                <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
                <ds:DigestValue>{digest}</ds:DigestValue>
            </ds:Reference>
        </ds:SignedInfo>
        <ds:SignatureValue>{signature}</ds:SignatureValue>
        <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
            <X509Data>
                <X509Certificate>{cert}</X509Certificate>
            </X509Data>
        </KeyInfo>
    </ds:Signature>
</saml:Assertion>
alex00321 commented 4 years ago

@JonathanHolvey Hi I'm new to this case, but I'm trying to use sharePy to post file. The problem I got here is I don't have the main site like company.sharepoint.com. I only could access the sub site like company.sharepoint.com/sites/mine. So is there any way you could help? Thanks!

JonathanHolvey commented 4 years ago

@alex00321 please see the new issue (linked above) I've opened for your problem.

alex00321 commented 4 years ago

Any update @JonathanHolvey ? Thanks!

Nargizzz commented 4 years ago

Hello Guys!

Could you find a way to solve this issue? NameSpaceType for me is also Federated and I am using Sharepoint Online.

JonathanHolvey commented 3 years ago

I've implemented the fix proposed by @Bliss161 in https://github.com/JonathanHolvey/sharepy/commit/905cf23ebc5bf16f08459e543c87bc85e1d03a1a. Please can you check and confirm it works as expected?

pavanchhatpar commented 2 years ago

Hi,

I've checked branch release-2.0.0-beta (version 2.0.0b1.post2) and it works as expected, could you make a release of this beta version? Here's my snippet that I tried on a Federated NameSpaceType

import io
import sharepy
import pandas as pd

URL = 'https://myorg.sharepoint.com'
FILE_URL = '/relative/path/to/file.xlsx'
SHAREPOINT_USER = 'user@myorg.com'
SHAREPOINT_PASSWORD = 'Password!'

s = sharepy.connect(URL, username=SHAREPOINT_USER, password=SHAREPOINT_PASSWORD)
r = s.get(URL+FILE_URL)
f = io.BytesIO(r.content)
df = pd.read_excel(f)
JonathanHolvey commented 2 years ago

I've converted the beta to a full v2.0.0 release which is now available on PyPi. You can install the latest version using Pip:

pip install sharepy==2.0.0
sidduk83 commented 2 years ago

Hi @rajmetti & @JonathanHolvey,

i'm also using on-premise SP, could you please help me with code. Above code is showing error to me.

`import sharepy

URL = 'https://some_text.companynet.net' SHAREPOINT_USER = 'email_id' SHAREPOINT_PASSWORD = 'Password'

s = sharepy.connect(URL, username=SHAREPOINT_USER, password=SHAREPOINT_PASSWORD)`

Running this code on Windows OS, Sharepy 2.0, Python 3.7, Pycharm IDE

Error: sharepy.errors.AuthError: Unknown authentication error

Let me know if you need more information.

rajmetti commented 2 years ago

Try using office365, working for me

sidduk83 commented 2 years ago

I tried that as well, i have few questions, do i need to feed DNS, port and other details in code?

if you could help me with code here, that would have been helpful.

jennifer-klemisch-seagen commented 2 years ago

I'm getting the same error as sidduk83 - but with a `Managed

microsoftonline.com urn:federation:MicrosoftOnline` ERROR: File "C......\lib\site-packages\sharepy\auth\spol.py", line 50, in _get_token raise errors.AuthError.fromxml(root) sharepy.errors.AuthError: Unknown authentication error sharepy v2; py 3.8.10 Thank you in advance
rajmetti commented 2 years ago

Hi, as i mentioned, can you please try office 365 library. im providing an example go and check this out. it is working for me as of now. i'm behind on-premise network though. https://github.com/vgrem/Office365-REST-Python-Client/blob/master/examples/sharepoint/files/download_file_from_url.py