OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Python API GET Request "authorization failure" question

  • Thread starter Thread starter kenomote
  • Start date Start date
K

kenomote

Guest
I tried testing API request using python and I am new at this, I am able to authorize properly and get the bearer token however for the GET request it seems that it is failing.

Code:
import requests
import json

MainURL = "api.mysite.com/"
DataForm = {'scope': 'api-tenant',
            'grant_type': 'client_credentials',
            'client_id': 'client id',
            'client_secret': 'client secret'
            }

AuthData = requests.post(MainURL + "oauth/token", data=DataForm)
print(AuthData.text)
AuthCont = json.loads(AuthData.text)

autHeader = {'Authorization': 'Bearer' + AuthCont["access_token"], 'Accept': 'application/json'}

GetApp = requests.get(MainURL + "api/v3/applications", headers=autHeader, verify=False)

print(GetApp.text)

Need help.

Many thanks.
<p>I tried testing API request using python and I am new at this, I am able to authorize properly and get the bearer token however for the GET request it seems that it is failing.</p>

<pre><code>import requests
import json

MainURL = "api.mysite.com/"
DataForm = {'scope': 'api-tenant',
'grant_type': 'client_credentials',
'client_id': 'client id',
'client_secret': 'client secret'
}

AuthData = requests.post(MainURL + "oauth/token", data=DataForm)
print(AuthData.text)
AuthCont = json.loads(AuthData.text)

autHeader = {'Authorization': 'Bearer' + AuthCont["access_token"], 'Accept': 'application/json'}

GetApp = requests.get(MainURL + "api/v3/applications", headers=autHeader, verify=False)

print(GetApp.text)
</code></pre>

<p>Need help.</p>

<p>Many thanks.</p>
 

Latest posts

Top