Create: OAuth type
Description
Use a HTTP POST request to create a OAuth2.0 credential.
Request
HTTP Method: POST
| Parameter | Description |
|---|---|
| name | Name of the credential. |
| mode | Describes the type of credential (OAUTH). |
| oauth_url | Your app's OAuth authorization URL. Required when oauth_grant_type is authorization_code, unless you send oauth_authorization_code. |
| oauth_token_url | Your app's OAuth token URL. |
| oauth_client_id | Your app's client ID. |
| oauth_client_secret | Your app's client secret. |
| oauth_scope | One or more scope values for the parts of the user's account you want to access. |
| oauth_grant_type | Tines supports client_credentials and authorization_code grants. |
| team_id | ID of Tines Team where the credential will be located. |
| oauthPkceCodeChallengeMethod | Optional PKCE challenge method (S256, plain). default: NULL (None). Can't be used with oauth_authorization_code; send oauth_code_verifier instead. |
| oauth_authorization_code | Optional An authorization code your own OAuth app got from the provider. Tines exchanges it for tokens instead of returning a redirect_url. Requires oauth_redirect_uri, and oauth_grant_type must be authorization_code. |
| oauth_redirect_uri | Optional The redirect URI your app used to get oauth_authorization_code. Required with, and only accepted with, oauth_authorization_code. |
| oauth_code_verifier | Optional The PKCE code verifier your app used to get oauth_authorization_code, if any. Must be 43-128 characters of letters, numbers, and -._~. Only accepted with oauth_authorization_code. |
| folder_id | Optional ID of folder to which the credential will be located |
| read_access | Optional Control where this credential can be used (TEAM, GLOBAL). default: TEAM |
| shared_team_slugs | Optional List of teams' slugs where this credential can be used. Required to set read_access to SPECIFIC_TEAMS. default: [] (empty array). |
| description | Optional Description of the credential. default: "" (empty string). |
| metadata | Optional Key/value metadata relevant to the credential that can be referenced via the INFO path. |
| allowed_hosts | Optional Array of domains where this credential can only be used in HTTP requests. Domain matching supports wildcards. |
| live_credential_id | Optional ID of the live credential |
| expires_at | Optional ISO 8601 Timestamp representing date and time the credential will expire. Default: null. See: Credential expiry |
| expiry_notifications_enabled | Optional A boolean value stating whether or not expiry notifications are enabled. Default: false. See: Credential expiry email reminders |
| credential_notification_recipient_user_ids | Optional List of user IDs that will be sent credential notifications (e.g. expiry notifications) |
Sample request
curl -X POST \
https://<tenant-domain>/api/v1/user_credentials \
-H 'content-type: application/json' \
-H 'Authorization: Bearer <<CREDENTIAL.tines_api_key>>' \
-d '{
"name": "oauth credential",
"mode": "OAUTH",
"team_id": 2,
"oauth_url": "https://example.com/auth",
"oauth_token_url": "https://example.com/token",
"oauth_client_id": "foo",
"oauth_client_secret": "bar",
"oauth_scope": "sync",
"oauth_grant_type": "authorization_code"
}'
Sample request with an existing authorization code
Use this when your own OAuth app has already completed the authorization flow. Authorization codes are short-lived and single-use, so send the request soon after your app receives the code.
Request offline access when your app gets the code so the provider returns a refresh token. Without a refresh token, the credential stops working when the access token expires.
curl -X POST \
https://<tenant-domain>/api/v1/user_credentials \
-H 'content-type: application/json' \
-H 'Authorization: Bearer <<CREDENTIAL.tines_api_key>>' \
-d '{
"name": "oauth credential",
"mode": "OAUTH",
"team_id": 2,
"oauth_token_url": "https://example.com/token",
"oauth_client_id": "foo",
"oauth_client_secret": "bar",
"oauth_scope": "sync",
"oauth_grant_type": "authorization_code",
"oauth_authorization_code": "<<authorization_code>>",
"oauth_redirect_uri": "https://example.com/callback",
"oauth_code_verifier": "<<code_verifier>>"
}'
Response
A successful request will return a JSON object containing a redirect_url to complete the registration process and a description of the created credential.
If you send oauth_authorization_code, Tines exchanges the code during the request and the response doesn't include redirect_url. If the exchange fails, Tines doesn't create the credential and returns a 422 error.
Field description
| Parameter | Description |
|---|---|
| id | credential ID. |
| name | Name of the credential. |
| mode | Describes the type of credential (TEXT, JWT, OAUTH, AWS, MTLS, HTTP_REQUEST_AGENT, MULTI_REQUEST). |
| team_id | ID of team to which the credential belongs. |
| folder_id | ID of folder to which the credential belongs. |
| read_access | Control where this credential can be used (TEAM, GLOBAL, SPECIFIC_TEAMS). default: TEAM. (SPECIFIC_TEAMS is a premium feature. Reach out to find out more.) |
| shared_team_slugs | List of teams' slugs where this credential can be used. Required to set read_access to SPECIFIC_TEAMS. default: [] (empty array). |
| description | Description of the credential. |
| slug | An underscored representation of the credential name |
| created_at | ISO 8601 Timestamp representing date and time the credential was created. |
| updated_at | ISO 8601 Timestamp representing date and time the credential was last updated. |
| allowed_hosts | Array of domains where this credential can only be used in HTTP requests |
| metadata | Key/value metadata relevant to the credential |
| redirect_url | Redirect URL of the created credential. Not included when you send oauth_authorization_code. |
| restriction_type | The type of restriction applied to the use of the credential (RESTRICTED,RESTRICTED_TO_CREDENTIALS ,UNRESTRICTED ) |
| test_credential_enabled | A boolean value stating if the credential is enabled for using a test credential |
| test_credential | Data specific to the test credential (created_at and updated_at) |
| owner | An object representing the user who owns this credential. By default, the owner is the user who created the credential. |
| expires_at | ISO 8601 Timestamp representing date and time the credential will expire. Default: null. See: Credential expiry |
| expiry_notifications_enabled | A boolean value stating whether or not expiry notifications are enabled. Default: false. See: Credential expiry email reminders |
| credential_notification_recipient_user_ids | List of user IDs that will be sent credential notifications (e.g. expiry notifications) |
Sample response
{
"redirect_url": "",
"id": 1,
"name": "tines_api_credential",
"mode": "OAUTH",
"team_id": 2,
"folder_id": 1,
"read_access": "TEAM",
"shared_team_slugs": [],
"slug": "tines_api_credential",
"created_at": "2021-03-26T12:34:16.540Z",
"updated_at": "2021-03-26T12:34:16.540Z",
"description": "",
"allowed_hosts": [],
"metadata": {},
"restriction_type": "UNRESTRICTED",
"test_credential_enabled": false,
"owner": {
"user_id": 1,
"first_name": "Jane",
"last_name": "Doe",
"email": "jane@tines.io"
}
}