Insomnia: [Question] Duplicate "Bearer" String on Auth Method Chaining

Created on 12 Oct 2017  路  4Comments  路  Source: Kong/insomnia

  • Insomnia Version: 5.8.4.1085
  • Operating System: MacOS 10.13

Details

When Chaining Authentication Requests and using the Bearer Auth Method, Chained Request will contain "Bearer" string twice:

Chain Example:

  1. First Request: will return Authorization in Response Header in format "Bearer "
  2. Second Request: Uses Bearer Auth Method with Value of Previous Request's Authorization Header

The Second Request will have Bearer string twice since One will be added by Auth Method and the second one already exists in Authorization Response header.

I've tried setting Second Request's to {% filter replace("Bearer ", "") %}{% response 'header', 'req_81f8f8cb2aa147ef96ff3f88c593b322', 'Authorization' %}{% endfilter %} with no luck.

The only workaround I've found is that do not use built-in Auth Method(Set to No Authentication) and try setting the Header in Header Panel Manually.

Most helpful comment

Hmm, I tried that as well and it didn't work. However it did work with

{% filter replace('Bearer ', '') %}Bearer 12345{% endfilter %}

so I'm not sure what the problem is with using the response tag instead (I'll look into it).

I'm not sure if this will work for you, but a common way to do this sort of thing is to nest environment variables. If you set an environment variable to

{
  "variable": "{% response 'header', 'req_123', 'Authorization' %}"
}

you can use it with regular variable syntax like

{{ my_variable | replace('Bearer ', '') }}

All 4 comments

Hmm, I tried that as well and it didn't work. However it did work with

{% filter replace('Bearer ', '') %}Bearer 12345{% endfilter %}

so I'm not sure what the problem is with using the response tag instead (I'll look into it).

I'm not sure if this will work for you, but a common way to do this sort of thing is to nest environment variables. If you set an environment variable to

{
  "variable": "{% response 'header', 'req_123', 'Authorization' %}"
}

you can use it with regular variable syntax like

{{ my_variable | replace('Bearer ', '') }}

Tnx for the quick & helpful response, I'll try using env variables, tnx.

@gschier

It works well, Thank you very much

You're welcome 馃槃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Fyb3roptik picture Fyb3roptik  路  4Comments

dextermb picture dextermb  路  3Comments

isobit picture isobit  路  4Comments

kalinchernev picture kalinchernev  路  4Comments

Natfan picture Natfan  路  3Comments