Getting Error {401:“Unauthorized”} when trying to create jira issue through api using python

I wanted to create Jira issues through my OAuth 2.0 (3LO) app. So I followed the ‘’ documentation and I were able to create the ‘access token’ successfully. The scopes I used are [‘write:jira-work read:jira-user read:me’].
Then I received the cloud_id successfully and received the details of the logged in user.
Then I checked the site access for the app.
But, when I try to create an issue (document: in Jira it returns the error [“code”:401,“message”:“Unauthorized”]. I am using email(logged in user email) and API token to authorize. In the developer console, I’ve given the necessary permissions.
It would be great if you could help me to find out the reason for this error.

My python code for jira issue creation is as follows:

header = {'Accept':'application/json','Content-Type':'application/json'}
data = { 'fields': 
                'summary': summary,
                'issuetype':{'name': issue_type}

response = requests.request('POST', url =''%(request.session.get('cloud_id')), data = json.dumps(data), headers=header, auth=HTTPBasicAuth(email,token))


I feel like my problem is in,
auth=HTTPBasicAuth(email, token) parameter. here I’m sending ‘email’ and ‘token’ as strings. If it is wrong can someone please advice me how to write it.
I’m referring, “”. I’m using python.

Thank you.