sharepy icon indicating copy to clipboard operation
sharepy copied to clipboard

AADSTS50126: Error validating credentials due to invalid username or password

Open rajmetti opened this issue 4 years ago • 48 comments

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

rajmetti avatar Jan 16 '20 10:01 rajmetti

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', '[email protected]', password='1csAean6ZtwahpF3')

JonathanHolvey avatar Jan 16 '20 11:01 JonathanHolvey

okay ill try and report back

rajmetti avatar Jan 16 '20 12:01 rajmetti

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

rajmetti avatar Jan 16 '20 12:01 rajmetti

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

  • A different user account
  • A username that doesn't exist
  • An intentionally incorrect password

JonathanHolvey avatar Jan 16 '20 20:01 JonathanHolvey

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 avatar Jan 17 '20 06:01 rajmetti

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

rajmetti avatar Jan 17 '20 07:01 rajmetti

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

JonathanHolvey avatar Jan 17 '20 09:01 JonathanHolvey

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

rajmetti avatar Jan 17 '20 09:01 rajmetti

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

JonathanHolvey avatar Jan 18 '20 03:01 JonathanHolvey

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

rajmetti avatar Jan 21 '20 07:01 rajmetti

> <RealmInfo Success="true">
> <State>3</State>
> <UserState>2</UserState>
> <Login>[email protected]</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>``

rajmetti avatar Jan 21 '20 07:01 rajmetti

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

JonathanHolvey avatar Jan 21 '20 21:01 JonathanHolvey

okay let me try and ill post the result .

rajmetti avatar Jan 22 '20 05:01 rajmetti

i tried this code

import sharepy

auth = sharepy.auth.SharePointOnline(username="[email protected]")
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'

rajmetti avatar Jan 22 '20 12:01 rajmetti

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)

JonathanHolvey avatar Jan 22 '20 19:01 JonathanHolvey

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

rajmetti avatar Jan 23 '20 04:01 rajmetti

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

rajmetti avatar Jan 23 '20 07:01 rajmetti

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.

JonathanHolvey avatar Jan 23 '20 11:01 JonathanHolvey

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 avatar Jan 23 '20 11:01 rajmetti

this is the output it showing

rajmetti avatar Jan 23 '20 11:01 rajmetti

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.

JonathanHolvey avatar Jan 23 '20 12:01 JonathanHolvey

okay @JonathanHolvey , ill let you know the result

rajmetti avatar Jan 23 '20 13:01 rajmetti

<?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 avatar Jan 23 '20 13:01 rajmetti

@JonathanHolvey any other way

rajmetti avatar Jan 30 '20 10:01 rajmetti

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?

JonathanHolvey avatar Jan 30 '20 11:01 JonathanHolvey

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 avatar Jan 30 '20 12:01 rajmetti

@JonathanHolvey No ADFS

rajmetti avatar Jan 31 '20 07:01 rajmetti

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

rajmetti avatar Feb 03 '20 10:02 rajmetti

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

JonathanHolvey avatar Feb 03 '20 11:02 JonathanHolvey

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

rajmetti avatar Feb 03 '20 12:02 rajmetti

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.

JonathanHolvey avatar Feb 06 '20 12:02 JonathanHolvey

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)

Bliss161 avatar Feb 15 '20 07:02 Bliss161

@JonathanHolvey okay,

rajmetti avatar Feb 20 '20 05:02 rajmetti

@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

JonathanHolvey avatar Feb 20 '20 07:02 JonathanHolvey

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

rbthomp avatar Mar 26 '20 21:03 rbthomp

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>

Bliss161 avatar Jun 02 '20 11:06 Bliss161

@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!

alex00321 avatar Jun 15 '20 08:06 alex00321

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

JonathanHolvey avatar Jun 15 '20 08:06 JonathanHolvey

Any update @JonathanHolvey ? Thanks!

alex00321 avatar Jun 22 '20 01:06 alex00321

Hello Guys!

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

Nargizzz avatar Jun 29 '20 14:06 Nargizzz

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?

JonathanHolvey avatar Jan 02 '21 03:01 JonathanHolvey

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 = '[email protected]'
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)

pavanchhatpar avatar Nov 17 '21 15:11 pavanchhatpar

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

JonathanHolvey avatar Feb 05 '22 05:02 JonathanHolvey

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.

sidduk83 avatar Mar 14 '22 07:03 sidduk83

Try using office365, working for me

rajmetti avatar Mar 14 '22 12:03 rajmetti

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.

sidduk83 avatar Mar 14 '22 13:03 sidduk83