Getting Authorization Error Python

Hi All ,

I am trying to access a page using Python script.
I have created a Personal Access Token and used it in the Python code.
My Code :

import requests
import json
from requests.auth import HTTPBasicAuth
import base64

encoded = base64.b64encode(b'Email Id : Personalized Access Token')
print ( encoded )

url = "url/<pageid>/child/attachment?start=0&limit=1000" 

headers = {
    'Authorization': "Basic <encoded string copied here >",
    'Cache-Control': "no-cache",

proxies = {
 "http": <proxy>,
 "https": <proxy> ,

params1 = (
    ('status', 'current'),

params2 = (
    ('status', 'trashed'),

response = requests.request("GET", url, headers=headers, proxies=proxies)

I am getting the below error:

SSLError: HTTPSConnectionPool(host='', port=443): Max retries exceeded with url:   (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),))

Can someone please help , I have tried all permutations and combinations and read many pages but unable to fix this error.


First of all, if you’re accessing then you want the Jira Server REST apis, not the Cloud REST apis.

It’s likely the error isn’t your authentication. Looking at the error it says it’s an SSL error with bad handshake and ssl3_get_server_certificate. Does the site run on a self generated SSL certificate or one that has incomplete certification chain? If so, you’ll need to provide Python with the missing certificates.

Depending on your system, for example if it’s Ubuntu or Debian, you can run sudo apt install ca-certificates and this may add the certificate to the system. Or with Windows try pip install python-certifi-win32.

But if you have your own certificate chain you’ll need to let Python know about the certificates with something like

response = requests.request("GET", url, headers=headers, proxies=proxies, verify = 'mycerts.pem')

You can also check out some other responses if they help.


1 Like