title: Subscribe to Microsoft Office 365 Management Activity API: Authorization denied
body: <p>I try to subscribe to Office 365 Management API and fail.</p>
  
  <p>posting to <a href="https://manage.office.com/api/v1.0/" rel="nofollow">https://manage.office.com/api/v1.0/</a>{tennant-id}/activity/feed/sub
  scriptions/start?contentType=Audit.SharePoint
  Returns with the following error:</p>
  
  <pre><code>&lt;Response [401]&gt; {"Message":"Authorization has been denied for this request."}
  </code></pre>
  
  <p>When using local python environment.
  I already have access Token, which I use it to print the office 365 root website and connect to Azure Active Directory.
  I suspected the error was in the way I created the Microsoft azure web app, therefore I created a new azure web-app which ended with the same result, also when I creating “Native Client app” ended with the same result.
  When I use an 'web app python console', for exampl 'pythonanywhere', an exception is being thron, with the following error:
  “Cannot connect to proxy. Socket error: Tunnel connection failed: 403 Forbidden.”</p>
  
  <p>I followed Microsoft Manual: <a href="https://msdn.microsoft.com/en-us/library/office/mt227394.aspx#StartSubscription" rel="nofollow">https://msdn.microsoft.com/en-us/library/office/mt227394.aspx#StartSubscription</a></p>
  
  <p>Sample of my code:</p>
  
  <pre><code>tid = {my tenant ID}
  subscriptionHeader = { 'Content-Type': 'application/json; utf-8' , 'Authorization': 'Bearer %s' % (access_token)}
  subscriptionBody = {"webhook" : {
         "address": {my site} } }
  subscribtionPostUrl = "https*://manage.office.com/api/v1.0/%s/activity/feed/subscriptions/start?contentType=Audit.SharePoint" %(tid)
  print ("posting to %s\n" % (subscribtionPostUrl) )
  subscribtionPost = requests.post(subscribtionPostUrl, data=subscriptionBody, headers=subscriptionHeader)
  print ("subscribtionPost %s\n" % (subscribtionPost ) )
  print ("subscribtionPost %s\n" % (subscribtionPost.text ) )
  </code></pre>