Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Slack + Auth0
  1. Install the Custom Social Connections extension
  2. Click on the Slack button to install the Slack connection
  3. Enter a Slack Client ID and Secret. To get those go to: Fill the fields and pay special attention to the Redirect URI. Enter: See screenshots below.
  4. Click on App Credentials on the left and copy the Client ID and Client Secret and paste them on the Auth0 dashboard
  5. Click Save and then try the flow using the Try button. You should get back the full profile from Slack, including email, team and avatars.

Note: you can change the scopes on the Scope field on Auth0 and include any of these:

You can now use the Slack connection using any Auth0 client library. Example:

<script src=""></script>
<script type="text/javascript">
  var auth0 = new Auth0({
    domain:       '',
    clientID:     'AUTH0 CLIENTID',
    callbackOnLocationHash: true

   $('.login-slack').click(function () {
      connection: 'slack'

  $(function () {
    var result = auth0.parseHash(window.location.hash);

    //use result.idToken to call your rest api

    if (result && result.idToken) {
    // optionally fetch user profile
    auth0.getProfile(result.idToken, function (err, profile) {
      alert('hello ' +;

    // If offline_access was a requested scope
    // You can grab the result.refresh_token here

    } else if (result && result.error) {
        alert('error: ' + result.error);

You could also add a button to Lock

The resulting profile looks something like this:

  "name": "Foo Bar",
  "email": "",
  "image_24": "",
  "image_32": "",
  "image_48": "",
  "image_72": "",
  "image_192": "",
  "image_512": "",
  "slack_id": "U0AAAAH2U",
  "team": {
    "id": "T03GFRH2E",
    "name": "Foo Bar Team",
    "domain": "foobar",
    "image_34": "",
    "image_44": "",
    "image_68": "",
    "image_88": "",
    "image_102": "",
    "image_132": "",
    "image_original": ""
  "clientID": "15J4IrnfXxf86nDC5ajwhHUVJfjBhRnv",
  "updated_at": "2016-05-15T21:26:12.753Z",
  "picture": "",
  "user_id": "oauth2|slack|U0AAAAH2U",
  "nickname": "matias",
  "identities": [
      "provider": "oauth2",
      "access_token": "xoxp-3559867082--REDACTED-43092912710-5628baf147",
      "user_id": "slack|U0AAAAH2U",
      "connection": "slack",
      "isSocial": true
  "created_at": "2016-05-15T21:26:12.753Z",
  "sub": "oauth2|slack|U0AAAAH2U"

Note the identities[0].access_token is the Slack token you can use to call the Slack API furthermore.


Create Slack App

Get Client ID and Secret

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment