# CustomApiBuilder

## Overview

The `CustomApiBuilder` facilitates the configuration of the OAuth plugin for integration with less common or custom providers, including in-house solutions. This includes options for parsing and handling tokens, specifying request methods, and configuring authentication and endpoint URLs for token-related operations such as access, refresh, and revocation.

It supports methods to customize the API by enabling access token extraction, specifying token request methods, defining client authentication mechanisms, and setting up refresh and revoke token endpoints, allowing integration with a variety of OAuth implementations.

## Methods Summarized

| Type                                                                                                         | Name                                                                                             | Summary                                                                                                     |
| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------- |
| [CustomApiBuilder](https://docs.servoy.com/reference/servoyextensions/server-plugins/oauth/customapibuilder) | [withAccessTokenExtractor(accessTokenExtractor)](#withaccesstokenextractor-accesstokenextractor) | Configures the api with a token extractor which parses the concrete type of token from the response string. |
| [CustomApiBuilder](https://docs.servoy.com/reference/servoyextensions/server-plugins/oauth/customapibuilder) | [withAccessTokenMethod(tokenRequestMethod)](#withaccesstokenmethod-tokenrequestmethod)           | The request method used for the access token endpoint (defaults to POST).                                   |
| [CustomApiBuilder](https://docs.servoy.com/reference/servoyextensions/server-plugins/oauth/customapibuilder) | [withClientAuthentication(clientAuthentication)](#withclientauthentication-clientauthentication) | Configures the api with a client authentication method which specifies how the client credentials are sent. |
| [CustomApiBuilder](https://docs.servoy.com/reference/servoyextensions/server-plugins/oauth/customapibuilder) | [withRefreshTokenEndpoint(refreshTokenEndpoint)](#withrefreshtokenendpoint-refreshtokenendpoint) | Configure the api with the URL that receives the refresh token requests.                                    |
| [CustomApiBuilder](https://docs.servoy.com/reference/servoyextensions/server-plugins/oauth/customapibuilder) | [withRevokeTokenEndpoint(revokeTokenEndpoint)](#withrevoketokenendpoint-revoketokenendpoint)     | Configure the api with the URL that receives the revoke token requests.                                     |

## Methods Detailed

### withAccessTokenExtractor(accessTokenExtractor)

Configures the api with a token extractor which parses the concrete type of token from the response string.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **accessTokenExtractor** see plugins.oauth.OAuthTokenExtractors

**Returns:** [CustomApiBuilder](https://docs.servoy.com/reference/servoyextensions/server-plugins/oauth/customapibuilder) the api builder for method chaining

### withAccessTokenMethod(tokenRequestMethod)

The request method used for the access token endpoint (defaults to POST).

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **tokenRequestMethod** can be 'post' or 'get'

**Returns:** [CustomApiBuilder](https://docs.servoy.com/reference/servoyextensions/server-plugins/oauth/customapibuilder) the api builder for method chaining

### withClientAuthentication(clientAuthentication)

Configures the api with a client authentication method which specifies how the client credentials are sent.\
They can be sent as basic Auth header or in the request body.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **clientAuthentication** see plugins.oauth.ClientAuthentication

**Returns:** [CustomApiBuilder](https://docs.servoy.com/reference/servoyextensions/server-plugins/oauth/customapibuilder) the api builder for method chaining

### withRefreshTokenEndpoint(refreshTokenEndpoint)

Configure the api with the URL that receives the refresh token requests.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **refreshTokenEndpoint** ;

**Returns:** [CustomApiBuilder](https://docs.servoy.com/reference/servoyextensions/server-plugins/oauth/customapibuilder) the api builder for method chaining

### withRevokeTokenEndpoint(revokeTokenEndpoint)

Configure the api with the URL that receives the revoke token requests.

**Parameters**

* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **revokeTokenEndpoint** ;

**Returns:** [CustomApiBuilder](https://docs.servoy.com/reference/servoyextensions/server-plugins/oauth/customapibuilder) the api builder for method chaining

***
