An OpenAPI 2.0 scheme uses the OAuth2 implicit flow

The OAuth2 implicit flow sends an access token directly in the authorization response.

Description

OpenAPI 2.0 flow: implicit returns the access token directly in the redirect response.

Potential impact

A leaked token can be reused. Accepting the wrong token can also associate a client session with the wrong account.

Remediation

Move the client and authorization server to the authorization code flow with PKCE. Set flow: accessCode in securityDefinitions and supply the provider’s HTTPS authorizationUrl and tokenUrl.

Examples

The authorization server verifies PKCE when the client exchanges its code for a token.

Before

json
{
  "securityDefinitions": {
    "oauth2": {
      "type": "oauth2",
      "flow": "implicit",
      "authorizationUrl": "https://api.example.com/oauth/authorize",
      "scopes": {}
    }
  }
}

After

json
{
  "securityDefinitions": {
    "oauth2": {
      "type": "oauth2",
      "flow": "accessCode",
      "authorizationUrl": "https://api.example.com/oauth/authorize",
      "tokenUrl": "https://api.example.com/oauth/token",
      "scopes": {}
    }
  }
}

References