# How can I setup auth for easier testing?

**URL:** <https://community.postman.com/t/how-can-i-setup-auth-for-easier-testing/47972>\
**Category:** Help Hub\
**Tags:** authentication\
**Created:** [May 30, 2023, 6:57pm UTC](https://community.postman.com/t/how-can-i-setup-auth-for-easier-testing/47972 "2023-05-30T18:57:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ba-tb](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@ba-tb](https://community.postman.com/u/ba-tb)\
**Post date:** [May 30, 2023, 6:57pm UTC](https://community.postman.com/t/how-can-i-setup-auth-for-easier-testing/47972/1 "2023-05-30T18:57:33Z")

</div>

My workflow is to push changes to my swagger docs, then convert those to Postman and run a PUT on /collections/{{collectionId}} to update my collection on Postman.

My Swagger doc defines two possible security options:  
OAuth2AccessCode  
OAuth2Application

I have security setup for each endpoint because I require different scopes for specific operations. Here’s an example of my GET on /account:

```auto
paths:
  /account:
    get:
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/Account'
      security:
      - OAuth2AccessCode:
        - app/read
      - OAuth2Application:
        - app/read
      summary: List the details for your account.
      tags:
      - account

```

When this gets imported into Postman via swagger2-to-postmanv2 conversion ([GitHub - postmanlabs/swagger2-postman2: Module and library to convert Swagger 2.0 to a Postman Collection (v2.0)](https://github.com/postmanlabs/swagger2-postman2)) I end up seeing this in the endpoint authorization:

 ![screenie](https://us1.discourse-cdn.com/getpostman/original/3X/6/b/6b44c791a72856d999aae16f13186ed23e5a5afd.png)

which isn’t really what I want.

At the collection level, I have a pre-request script to generate an auth token for the application flow and places it into my environment, which goes a lot nicer when I manually select “Bearer token” from the auth drop down in that screenie above.

If I leave it as is now, I can’t run the collection because it never gets proper authorization. Perhaps there’s something else about my collection update to set to allow for the pre-request script to provide proper authentication to the collection? Just fyi, the pre-request script stores the active token on the environment.

Which leads me to my question, how can I make this work a bit smoother instead of having to grab a new token from either the endpoint’s tab on Postman or changing it manually to “Bearer token” type auth?

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 22, 2025, 3:51pm UTC](https://community.postman.com/t/how-can-i-setup-auth-for-easier-testing/47972/2 "2025-04-22T15:51:25Z")

</div>

Closed on April 22, 2025, 3:51pm UTC


