concept api security in category api

appears as: API security
The Design of Web APIs

This is an excerpt from Manning's book The Design of Web APIs.

Designing APIs that make sense for their users and are usable is definitely important, but this must not be done without considering security. API security is not an afterthought that you can assume will be handled later (whenever that is) by the security people (whoever they are). Indeed, design and security are inextricably linked when creating an API or anything else.

Listing 12.8 Defining API security and attaching scopes to a goal
[...]
components:
  securitySchemes:    #1  
    BankingAPIScopes:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: "https://auth.bankingcompany.com/authorize"
          scopes:
            "transfer:create": Create transfers
            "transfer:read": List transfers
            [...]
[...]
paths:
  /transfers:
    post:
      summary: Create a money transfer
      security:    #2  
        - BankingAPIScopes:
          - "transfer:create"
          - "transfer:admin"
[...]

#1   Security and scope definitions
#2   Scopes needed to use the goal