skip to Main Content

I have basic auth on the website, how can I include two authorization methods in the header, Bearer and token?
Is it at all possible if so how, because if I give it like this:

enter image description here

This is when one overwrites the other and doesn’t work.

2

Answers


  1. If you use Postman to test the API, it already supports adding authorization when calling the API
    Access:
    In the Authorization section select Bearer Token and enter your token
    Note: You cannot add authorization to headers

    Login or Signup to reply.
  2. You can set multiple Authorizations using a comma

    Authorization: Basic X,Bearer Y
    

    X is the base64 encoded username:password. Basic must come before the Bearer.

    If you want to set it in the parent you may consider using pre-request script:

    const X = btoa('user:pass');
    const Y = 'BEARER TOKEN';
    pm.request.headers.add({
        key: 'Authorization',
        value: `Basic ${X},Bearer ${Y}`,
    });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search