title: Accessing Office365 Sharepoint REST EndPoints using Python (Office365 Sharepoint REST client for Python)
body: <p>I am trying to get access to a Sharepoint site from Python and it seems like AADSTS has a conditional access policy that’s preventing me from getting a token.</p>
  <p>Has anyone used the Office365 Python Rest Client to successful connect to a Sharepoint Rest Endpoint?</p>
  <p>This is the actual error I am seeing</p>
  <pre><code>&quot;C:\Python\envs\dev\python.exe c:\Users\xxxxxx.vscode\extensions\ms-python.python-2020.8.105369\pythonFiles\lib\python\debugpy\launcher 52801 -- c:\xxxx\Code\PythonSharepointUpdate\readsharepoint.py &quot; An error occurred while retrieving token from XML response: AADSTS53003: Access has been blocked by Conditional Access policies. The access policy does not allow token issuance. An error occurred while retrieving auth cookies from https://microsoft.sharepoint.com/_vti_bin/idcrl.svc/
  </code></pre>
  <pre><code>I am trying to execute this code from the Sample
  
      from office365.runtime.auth.user_credential import UserCredential 
      from office365.sharepoint.client_context import ClientContext 
      from office365.runtime.auth.authentication_context import AuthenticationContext 
      site_url = 'https://microsoft.sharepoint.com/teams/' 
      ctx = ClientContext(site_url).with_credentials(UserCredential(&quot;user@domain.com&quot;, &quot;My Complex Password”)) 
      web = ctx.web 
      ctx.load(web) 
      ctx.execute_query() 
      print(&quot;Web title: {0}&quot;.format(web.properties['Title']))
  </code></pre>
  <p>Also – is there a better way to authenticate to Sharepoint – I hate to have to type my Password in clear text in code ☹</p>
  <p>Has anyone use ClientCredential? Is there a seperate setup on the Sharepoint Site to enable ClientCredential? Does our Sharepoint let us do that?</p>