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

Hi,
I wanted to create Jira issues through my OAuth 2.0 (3LO) app. So I followed the ‘https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps/’ 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: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post) 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': 
                {'project':{'name':project}, 
                'summary': summary,
                'issuetype':{'name': issue_type}
                }
            }

response = requests.request('POST', url ='https://api.atlassian.com/ex/jira/%s/rest/api/3/issue'%(request.session.get('cloud_id')), data = json.dumps(data), headers=header, auth=HTTPBasicAuth(email,token))

Thanks.

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, “https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post”. I’m using python.

Thank you.