Django & Authorization Bearer Token

I'm working on Django for an app refrencial on job. I want to get data from an API Pole Emploi. I'm register on the web site, I got a client_id, client_secret etc. I do a get request to get my access_token.

def login_explo_metier_pole_emploi():
    params = {
        'grant_type': 'client_credentials',
        'client_id': 'XXX',
        'client_secret': 'XXX',
        'scope': 'api_explorateurmetiersv1 explojob'
    header = {
        'Content-Type': 'application/x-www-form-urlencoded'
    url_co = ''
    req_co =, params, header)
    wb = req_co.json()
    access_token = wb['access_token']
    print('reponse: ', wb)
    return access_token

That's working.

After, I want on my view, get datas, but here, it's not working :

    def get_rome(param):
        access = login_explo_metier_pole_emploi()
        print('acces avec: ', access)
        params = request.META.get('HTTP_AUTHORIZATION', f"Bearer {access}")
        url = f"{param}&nombre=20&type=metier"
        req = requests.get(url, params)
        return req

It's returned an 401 error (Unauthorized).

Can someone help me please?

Back to Top