Skip to main content

Auth0 API

All URIs are relative to http://localhost:1000

MethodHTTP requestDescription
auth0LogoutGET /v2/logouthttps://auth.pieces.services/v2/logout [GET]
authorizeAuth0GET /authorizehttps://auth.pieces.services/authorize [GET]
exchangeForAuth0TokenPOST /oauth/tokenhttps://auth.pieces.services/oauth/token [POST]
getAuth0UserInfoGET /userinfohttps://auth.pieces.services/userinfo [GET]

auth0Logout

string auth0Logout()

https://auth0.com/docs/api/authentication#logout

Example

import * as Pieces from '@pieces.app/pieces-os-client'

const configuration = Pieces.Configuration()
const apiInstance = new Pieces.Auth0Api(configuration)

const body: Pieces.Auth0LogoutRequest = {
// string | The client ID of the Auth0 Instance (optional)
clientId: clientId_example,
// string | The URL that the logout endpoint will return to (optional)
returnTo: returnTo_example,
};

apiInstance.auth0Logout(body).then((data: string) => {
console.log('API called successfully. Returned data: ' + data)
}).catch((error: unknown) => console.error(error))

Parameters

NameTypeDescriptionNotes
clientId[string]The client ID of the Auth0 Instance(optional) defaults to undefined
returnTo[string]The URL that the logout endpoint will return to(optional) defaults to undefined

Return type

string

HTTP request headers

  • Content-Type: Not defined
  • Accept: text/html

HTTP response details

Status codeDescriptionResponse headers
200OK-

authorizeAuth0

ResultedPKCE authorizeAuth0()

An endpoint that is used locally authenticate via a PKCE Flow. Example https://auth.pieces.services /authorize?audience=https%3A%2F%2Fpieces.us.auth0.com%2Fapi%2Fv2%2F&scope=email+profile+offline_access+openid&response_type=code&client_id=9sW4Pa1LEjX67l6VO14u0207NLYeXnu1&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fpkce%2Fresponse%2Fcode&code_challenge_method=S256&code_challenge=yxRssZxdfBpMigRmDxAety1QU72Bd5WnDUbtlsCZOnk&response_mode=form_post&state=4bd0b9a389b4b229602346c33913b4c3c199628a90011ab3a901302ab62b3832

Example

import * as Pieces from '@pieces.app/pieces-os-client'

const configuration = Pieces.Configuration()
const apiInstance = new Pieces.Auth0Api(configuration)

const body: Pieces.AuthorizeAuth0Request = {
// string | The unique identifier of the target API you want to access.
audience: `https://pieces.us.auth0.com`/api/v2/,
// Array\<'openid' | 'email' | 'profile' | 'offline_access'\> | The scopes which you want to request authorization for. These must be separated by a space. You can request any of the standard OpenID Connect (OIDC) scopes about users, such as profile and email, custom claims that must conform to a namespaced format, or any scopes supported by the target API (for example, read:contacts). Include offline_access to get a Refresh Token.
scope: ,
// 'code' | Indicates to Auth0 which OAuth 2.0 Flow you want to perform. Use code for Authorization Code Grant (PKCE) Flow.
responseType: code,
// string | Your application\'s Client ID.
clientId: 9sW4Pa1LEjX67l6VO14u0207NLYeXnu1,
// 'S256' | Method used to generate the challenge. The PKCE spec defines two methods, S256 and plain, however, Auth0 supports only S256 since the latter is discouraged.
codeChallengeMethod: S256,
// string | Generated challenge from the code_verifier.
codeChallenge: yxRssZxdfBpMigRmDxAety1QU72Bd5WnDUbtlsCZOnk,
// 'form_post' | 'fragment' | 'query' | 'web_message'
responseMode: responseMode_example,
// string | An opaque value the clients adds to the initial request that Auth0 includes when redirecting the back to the client. This value must be used by the client to prevent CSRF attacks. (optional)
state: state_example,
// string | The URL to which Auth0 will redirect the browser after authorization has been granted by the user. (optional)
redirectUri: redirectUri_example,
// string | The name of the connection configured to your application. (optional)
connection: connection_example,
// string | To initiate a silent authentication request, use prompt=none (see Remarks for more info). (optional)
prompt: prompt_example,
};

apiInstance.authorizeAuth0(body).then((data: ResultedPKCE) => {
console.log('API called successfully. Returned data: ' + data)
}).catch((error: unknown) => console.error(error))

Parameters

NameTypeDescriptionNotes
audience[string]The unique identifier of the target API you want to access.defaults to undefined
scopeArray<'openid' | 'email' | 'profile' | 'offline_access'>The scopes which you want to request authorization for. These must be separated by a space. You can request any of the standard OpenID Connect (OIDC) scopes about users, such as profile and email, custom claims that must conform to a namespaced format, or any scopes supported by the target API (for example, read:contacts). Include offline_access to get a Refresh Token.defaults to undefined
responseType['code']Array<'code'>Indicates to Auth0 which OAuth 2.0 Flow you want to perform. Use code for Authorization Code Grant (PKCE) Flow.defaults to undefined
clientId[string]Your application&#39;s Client ID.defaults to undefined
codeChallengeMethod['S256']Array<'S256'>Method used to generate the challenge. The PKCE spec defines two methods, S256 and plain, however, Auth0 supports only S256 since the latter is discouraged.defaults to undefined
codeChallenge[string]Generated challenge from the code_verifier.defaults to undefined
responseMode[**'form_post''fragment''query'
state[string]An opaque value the clients adds to the initial request that Auth0 includes when redirecting the back to the client. This value must be used by the client to prevent CSRF attacks.(optional) defaults to undefined
redirectUri[string]The URL to which Auth0 will redirect the browser after authorization has been granted by the user.(optional) defaults to undefined
connection[string]The name of the connection configured to your application.(optional) defaults to undefined
prompt[string]To initiate a silent authentication request, use prompt=none (see Remarks for more info).(optional) defaults to undefined

Return type

ResultedPKCE

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/x-www-form-urlencoded

HTTP response details

Status codeDescriptionResponse headers
200OK-

exchangeForAuth0Token

OAuthToken exchangeForAuth0Token()

An endpoint to generate a OAuth Token for an authentication flow.

Example

import * as Pieces from '@pieces.app/pieces-os-client'

const configuration = Pieces.Configuration()
const apiInstance = new Pieces.Auth0Api(configuration)

const body: Pieces.ExchangeForAuth0TokenRequest = {
// string | Denotes the flow you are using. For Authorization Code, use authorization_code or refresh_token.
grantType: grantType_example,
// string | Your application\\\'s Client ID.
clientId: clientId_example,
// string | The Authorization Code received from the initial /authorize call.
code: code_example,
// string | This is required only if it was set at the GET /authorize endpoint. The values must match.
redirectUri: redirectUri_example,
// string | Cryptographically random key that was used to generate the code_challenge passed to /authorize.
codeVerifier: codeVerifier_example,
// EmbeddedModelSchema (optional)
schema: ,
// string | The audience domain: i.e. `https://pieces.us.auth0.com` (optional)
audience: audience_example,
};

apiInstance.exchangeForAuth0Token(body).then((data: OAuthToken) => {
console.log('API called successfully. Returned data: ' + data)
}).catch((error: unknown) => console.error(error))

Parameters

NameTypeDescriptionNotes
grantType[string]Array<'refresh_token' | 'authorization_code'>Denotes the flow you are using. For Authorization Code, use authorization_code or refresh_token.defaults to undefined
clientId[string]Your application\&#39;s Client ID.defaults to undefined
code[string]The Authorization Code received from the initial /authorize call.defaults to undefined
redirectUri[string]This is required only if it was set at the GET /authorize endpoint. The values must match.defaults to undefined
codeVerifier[string]Cryptographically random key that was used to generate the code_challenge passed to /authorize.defaults to undefined
schemaEmbeddedModelSchema(optional) defaults to undefined
audience[string]The audience domain: i.e. https://pieces.us.auth0.com(optional) defaults to undefined

Return type

OAuthToken

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200OK-

getAuth0UserInfo

Auth0User getAuth0UserInfo()

Get the users info from the Auth0 API

Example

import * as Pieces from '@pieces.app/pieces-os-client'

const configuration = Pieces.Configuration()
const apiInstance = new Pieces.Auth0Api(configuration)

apiInstance.getAuth0UserInfo().then((data: Auth0User) => {
console.log('API called successfully. Returned data: ' + data)
}).catch((error: unknown) => console.error(error))

Parameters

This endpoint does not need any parameters.

Return type

Auth0User

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200OK-