Skip to Content
REST APILogin API

Login API

The login endpoints are implementing an OAuth2 flow.

Acquire token with OAuth2 authorization

PathMethodProtected
/v1/login/oauth2POSTNo

Gets a token by authorizing with an external OAuth2 provider. Currently only github is supported.

In the response:

  • id is the identifier of the token itself
  • accountId is the account’s identifier, can be used on the account API
  • secret is the secret key to be sent in the Authorization header as a bearer token for all the other endpoints

Query Parameters

NameTypeRequiredDescription
provider#/components/schemas/OAuth2ProviderYesCurrently only github is supported.
access-tokenstringYesOAuth2 access token

Example Response JSON

{ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "secret": "stringstringstri", "accountId": "3d07c219-0a88-45be-9cfc-91e9d095a1e9", "createdAt": "2019-08-24T14:15:22Z", "expiresAt": "2019-08-24T14:15:22Z" }

Initiate OAuth2 Web Flow

PathMethodProtected
/v1/login/oauth2/web/authorizePOSTNo

Starts the OAuth2 web flow. Two flow kinds are supported:

  • browser: The callback will immediately redirect to the given URL with the Golem token secret appended as a token query parameter. Intended for browser-based frontends.

  • cli: The callback stores the token in the session. The client polls the poll endpoint with the returned state id to retrieve the token once available. Intended for CLI tools and headless environments.

Example Request JSON

{ "type": "Browser", "provider": "github", "redirect": "string" }

Example Response JSON

{ "url": "string", "state": "0e231ca7-8c83-44ad-9df9-f0699a512c67" }

OAuth2 Web Flow callback

PathMethodProtected
/v1/login/oauth2/web/callbackGETNo

This endpoint handles the callback from the provider after the user has authorized the application. It exchanges the code for an access token and then uses that to log the user in.

Query Parameters

NameTypeRequiredDescription
codestringYesThe authorization code returned by GitHub
statestringYesThe state parameter for CSRF protection

Poll for OAuth2 Web Flow token

PathMethodProtected
/v1/login/oauth2/web/pollGETNo

This endpoint is used by clients to poll for the token after the user has authorized the application via the web flow. A given state might only be exchanged for a token once. Any further attempts to exchange the state will fail.

Query Parameters

NameTypeRequiredDescription
statestringYesThe state parameter for identifying the session

Example Response JSON

{ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "secret": "stringstringstri", "accountId": "3d07c219-0a88-45be-9cfc-91e9d095a1e9", "createdAt": "2019-08-24T14:15:22Z", "expiresAt": "2019-08-24T14:15:22Z" }

Login API Errors

Status CodeDescriptionBody
400Invalid request, returning with a list of issues detected in the request{"code":"string","errors":["string"]}
401Unauthorized request{"code":"string","error":"string"}
403Forbidden Request{"code":"string","error":"string"}
404Entity not found{"code":"string","error":"string"}
409{"code":"string","error":"string"}
422Limits of the plan exceeded{"code":"string","error":"string"}
500Internal server error{"code":"string","error":"string"}