# ‘Inherit auth from parent’ type of Authorization doesn’t work

**URL:** <https://community.postman.com/t/inherit-auth-from-parent-type-of-authorization-doesn-t-work/34923>\
**Category:** Help Hub\
**Created:** [May 2, 2022, 9:09am UTC](https://community.postman.com/t/inherit-auth-from-parent-type-of-authorization-doesn-t-work/34923 "2022-05-02T09:09:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![grrigore](https://avatars.discourse-cdn.com/v4/letter/g/779978/32.png) [@grrigore](https://community.postman.com/u/grrigore)\
**Post date:** [May 2, 2022, 9:09am UTC](https://community.postman.com/t/inherit-auth-from-parent-type-of-authorization-doesn-t-work/34923/1 "2022-05-02T09:09:38Z")

</div>

I’m using the following pre-request script for my collection:

```auto
let baseUrl = pm.variables.get("baseUrl");

const loginRequest = {
  url: `${baseUrl}/auth/login`, 
  method: 'POST',
  header: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
  },
  body: {
    mode: 'urlencoded',
    urlencoded : [
      { key: 'email', value: 'test@test.com'},
      { key: 'password', value: 'password'},
    ]
  }
};

pm.collectionVariables.unset("accessToken");
pm.collectionVariables.unset("refreshToken");

pm.sendRequest(loginRequest, function (err, response) {
    var jsonResponse = response.json()
    if (response.code == 200) {
        pm.collectionVariables.set("accessToken", jsonResponse.data.access_token);
        pm.collectionVariables.set("refreshToken", jsonResponse.data.refresh_token);
    } else {
        console.error("Login error")
    }
});

```

and I’ve set the authorization like this:

 ![Screenshot 2022-05-02 at 12.07.29](https://us1.discourse-cdn.com/getpostman/original/3X/f/4/f433cc147cc4bb0bfd9cd9f7547a46343a5dbab1.png)

However, sometimes it works fine, but sometimes I get 401, I’m not sure if it’s set correctly or not. I’m using no environment. Does this look ok to you? Are there any caches I have to clear?

LE: In the request header I can see the authorization is added.
