Facts
application/x-www-form-urlencoded application/json Arguments
Required arguments
client_idstringRequiredIssued when you created your application. Must be the app the token being rotated was issued to.
4123121235.9872358710client_secretstringRequiredIssued when you created your application.
e1b9e11dfcd19c1982d5de12921e17e8ctokenstringRequiredThe xoxp token being rotated.
xoxp-12345-67890-1928471-abcdefgUsage info
Use this API method alongside the oauth.v2.completeShortTokenRotation method to rotate a short-secret user token created before August 19, 2016 to a more secure token with a longer 32-character secret.
This is a one-time rotation. If you want to rotate token secrets periodically, see the token rotation documentation for more details.
1. Identify your tokens with short secret lengths
If you have timestamps available, you can filter for anything created prior to August 19, 2016.
If you aren't sure when a token was created, you can parse the strings and identify any with secrets fewer than 32 characters. The token is divided into several sections, separated by a - character. The final section is the secret. In this example, the secret is d6bc768406e5c2e6958cfc399b438004. Tokens created before August 2016 may have secrets with 6 or 10 characters instead of 32.
// A Slack token with a long secret
xoxp-111-222-333-d6bc768406e5c2e6958cfc399b438004
// Slack tokens created before August 2016
xoxp-111-222-333-d6bc76
xoxp-111-222-333-d6bc768412
2. Grab your app's client_id and client_secret credentials
These credentials are the same credentials you use with the oauth.v2.access method. You can find them on the Basic Information page of your app's configuration. The client_id must belong to the app the token was issued to.
3. Call the oauth.v2.beginShortTokenRotation method
For each token, call the oauth.v2.beginShortTokenRotation method and pass the token you want to update, along with your client_id and client_secret.
curl -X POST https://slack.com/api/oauth.v2.beginShortTokenRotation \
-H "Authorization: Bearer xoxp-35441797610-35912028499-1325414073906-d6bc768412" \
-H "Content-type: application/x-www-form-urlencoded" \
--data-urlencode "client_id=4123121235.9872358710" \
--data-urlencode "client_secret=e1b9e11dfcd19c1982d5de12921e17e8c"
The response will contain a new_token field.
{
"ok": true,
"new_token": "xoxp-35441797610-35912028499-1325414073906-6e813caca4c605e2a04f66eedf11dc09"
}
This change does not take effect until you complete the flow. Do not overwrite your original token until the flow is complete.
For each token, the rotation must be completed within 10 minutes. If more than 10 minutes pass between calling the oauth.v2.beginShortTokenRotation and oauth.v2.completeShortTokenRotation methods, you will need to start over.
4. Call the oauth.v2.completeShortTokenRotation method
Pass the original short token in the Authorization header of the call. Pass the new replacement token as the new_token parameter, along with the same client_id and client_secret.
curl -X POST https://slack.com/api/oauth.v2.completeShortTokenRotation \
-H "Authorization: Bearer xoxp-35441797610-35912028499-1325414073906-d6bc768412" \
-H "Content-type: application/x-www-form-urlencoded" \
--data-urlencode "client_id=4123121235.9872358710" \
--data-urlencode "client_secret=e1b9e11dfcd19c1982d5de12921e17e8c" \
--data-urlencode "new_token=xoxp-35441797610-35912028499-1325414073906-6e813caca4c605e2a04f66eedf11dc09"
If the response to this API call is successful, the original token will be invalidated and the new token will go live. The new token will be exactly the same as the original, but with a longer secret. The response echoes it back in the token field.
{
"ok": true,
"token": "xoxp-35441797610-35912028499-1325414073906-6e813caca4c605e2a04f66eedf11dc09"
}
If you do not get a successful response from oauth.v2.completeShortTokenRotation, the rotation may not have been completed. Call auth.test with the original and new token to check which is valid.
5. Call auth.test to confirm the new token is valid
If everything looks good, update your database with the new token.
Response
Successful start of a short token rotation. The new_token is not active until the rotation is completed with oauth.v2.completeShortTokenRotation.
{
"ok": true,
"new_token": "xoxp-35441797610-35912028499-1325414073906-6e813caca4c605e2a04f66eedf11dc09"
}
Errors
This table lists the expected errors that this method could return. However, other errors can be returned in the case where the service is down or other unexpected factors affect processing. Callers should always check the value of the ok parameter in the response.
access_deniedAccess to a resource specified in the request is denied.
accesslimitedAccess to this method is limited on the current network
account_inactiveAuthentication token is for a deleted user or workspace when using a bot token.
bad_client_secretValue passed for client_secret was invalid.
deprecated_endpointThe endpoint has been deprecated.
ekm_access_deniedAdministrators have suspended the ability to post a message.
enterprise_is_restrictedThe method cannot be called from an Enterprise.
fatal_errorThe server could not complete your operation(s) without encountering a catastrophic error. It's possible some aspect of the operation succeeded before the error was raised.
internal_errorA server-side error occurred.
internal_errorThe server could not complete your operation(s) without encountering an error, likely due to a transient issue on our end. It's possible some aspect of the operation succeeded before the error was raised.
invalid_arg_nameThe method was passed an argument whose name falls outside the bounds of accepted or expected values. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
invalid_argumentsThe method was called with invalid arguments.
invalid_array_argThe method was passed an array as an argument. Please only input valid strings.
invalid_authSome aspect of authentication cannot be validated. Either the provided token is invalid or the request originates from an IP address disallowed from making the request.
invalid_charsetThe method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
invalid_client_idValue passed for client_id was invalid, or is not the app the token being rotated was issued to.
invalid_form_dataThe method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
invalid_post_typeThe method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/json application/x-www-form-urlencoded multipart/form-data text/plain.
invalid_tokenThis token is invalid.
method_deprecatedThe method has been deprecated.
missing_post_typeThe method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
missing_scopeThe token used is not granted the specific scope permissions required to complete this request.
no_permissionThe workspace token used in this request does not have the permissions necessary to complete the request. Make sure your app is a member of the conversation it's attempting to post a message to.
not_allowed_token_typeThe token type used in this request is not allowed.
not_authedNo authentication token provided.
org_login_requiredThe workspace is undergoing an enterprise migration and will not be available until migration is complete.
ratelimitedThe request has been ratelimited. Refer to the Retry-After header for when to retry the request.
request_timeoutThe method was called via a POST request, but the POST data was either missing or truncated.
service_unavailableThe service is temporarily unavailable
team_access_not_grantedThe token used is not granted the specific workspace access required to complete this request.
team_added_to_orgThe workspace associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
token_expiredAuthentication token has expired
token_revokedAuthentication token is for a deleted user or workspace or the app has been removed when using a user token.
token_too_longThis token is not short enough to be rotated.
two_factor_setup_requiredTwo factor setup is required.
