How to mock a server protected by oauth2 auth_code flow?

Hi Postman Community,

I’m working through an api-first approach and building out my api using openapi 3.0. I would like to setup a mock server to run some tests against however, I am getting “authentication_error” when doing so. I’m assuming that I need to supply an oauth token, however, I’m not sure if I should setup my own oauth server to do so, or if postman has some server that works specifically with their mock server. Maybe I’m miss understanding this approach too. Any help would be appreciated.

Here is an example of an openapi 3.0 schema for the oauth flow I’m trying to use just in case it helps.

components:
  securitySchemes:
    OAuth2:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: accounts.example.com/authorize
          tokenUrl: accounts.example.com/token
          scopes:
            read: read scope
            write: write scope

security: 
  - OAuth2: 
    - write
    - read

paths:
  /orders:
    patch:
      summary: Creates a new order
      security: 
        - OAuth2:
          - write
          - read

OAuth2 is a complex topic and I don’t know if this is the best way to start learning about OpenAPI, mock servers, and tests.

From your description, it is not clear where is the “authentication_error” coming from.