OAuth2Endpoint

OAuth2Endpoint

Methods

(static) authorize()

As a user, create an authorization code for a specific client.

Request

  • path: /api/oauth/authorize
  • verb: POST
  • Content-Type: application/x-www-form-urlencoded
{
  "access_token": String,
  "state": String,
  "response_type": String,
  "client_id": String
}

Response

Status 200 - Success

{
  "authorizationCode": String,
  "expiresAt": Date,
  "redirectUri": String,
  "client": {
    "id": String
  },
  "user": {
    "email": String
  }
}
Source:

(static) client()

As a client, register yourself with the server.

Request

  • path: /api/oauth/client
  • verb: POST
{
  "redirectURL": String,
  "email": String,
  "name": String
}

Response

Status 200 - Success

{
  "clientId": String
}

Status 400 - Failure

{
  "message": String
}
Source:

(static) token()

Depending on request parameters:

  1. Exchange a code for tokens.
  2. Exchange username and password for tokens.
  3. Exchange a refresh token for a new access token.

Request

  • path: /api/oauth/token
  • verb: POST
  • Content-Type: application/x-www-form-urlencoded

1:

{
  "code": String,
  "grant_type": "authorization_code",
  "client_id": String,
  "redirect_uri": String
}

2:

{
  "username": String,
  "password": String,
  "grant_type": "password",
  "client_id": String,
}

3:

{
  "refresh_token": String,
  "grant_type": "refresh_token",
  "client_id": String,
}

Response

Status 200 - Success

{
  "accessToken": String,
  "accessTokenExpiresAt": String,
  "refreshToken": String,
  "refreshTokenExpiresAt": String,
  "client": {
     "id": String
   },
  "user": {
    "email": String
  }
}

Failure

{
  "code": Number,
  "message": String,
  "name": String
}
Source: