# Auth0

### **Social Connection Integration**

When adding a Social Connection, you will see BitBadges as a preconfigured option. This has everything setup for you. You will simply need to specify your client ID and client secret. You will also have to configure your redirect URI to match your Auth0 application's domain. This typically ends with /callback (for example, <https://dev-pgv803tz4ztg35oi.us.auth0.com/login/callback>).

### <https://marketplace.auth0.com/integrations/bitbadges>

<figure><img src="https://2198930329-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7R34Y0QZwgpUGaJnJ4dq%2Fuploads%2Fgit-blob-e84c231c93f7e9f761609043d6d32b51ba9e6db6%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2198930329-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7R34Y0QZwgpUGaJnJ4dq%2Fuploads%2Fgit-blob-ebcfe60f627221f3a5263a0149fa3433c050f190%2Fimage%20(299).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2198930329-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7R34Y0QZwgpUGaJnJ4dq%2Fuploads%2Fgit-blob-a7f4bf400b6d0aa12f2b46670ea0e8183e1b2c82%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### Custom

You can also customize the connection further by creating a custom connection. This allows you to add parameters beyond the standard flow. You callback will be the same as above.

<figure><img src="https://2198930329-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7R34Y0QZwgpUGaJnJ4dq%2Fuploads%2Fgit-blob-6920d2800d8d3a5fbcb79b65745df6a45a5fbb16%2Fimage%20(136).png?alt=media" alt=""><figcaption></figcaption></figure>

**Authorization URL:** <https://bitbadges.io/siwbb/authorize>

**Token URL:** <https://api.bitbadges.io/api/v0/siwbb/token>

**Scopes:** None (All you typically need is the user crypto address) - Although, you can add as needed

**Fields:** Get your API key, client ID, and client secret at <https://bitbadgesio/developer>.

**Fetch Profile Script**:

```javascript
function fetchUserProfile(accessToken, ctx, cb) {
    request.post(
        {
            url: 'https://api.bitbadges.io/api/v0/auth/status',
            headers: {
                'Content-Type': 'application/json',
                // TODO: Replace
                'x-api-key': 'ENTER_API_KEY_HERE',
                Authorization: 'Bearer ' + accessToken,
            },
        },
        (err, resp, body) => {
            if (err) {
                return cb(err);
            }
            if (resp.statusCode !== 200) {
                return cb(new Error(body));
            }
            let bodyParsed;
            try {
                bodyParsed = JSON.parse(body);
            } catch (jsonError) {
                return cb(
                    new Error('Failed JSON parsing for user profile response.')
                );
            }

            const account = bodyParsed;

            const profile = {
                address: account.address,
                chain: account.chain,
                id: account.bitbadgesAddress,
                name: account.address,
            };
            return cb(null, profile);
        }
    );
}
```

**Custom Headers:**

Make sure you enter your API key in the custom headers an d replace it in the fetch script.

```
{
    "x-api-key": "YOUR_API_KEY"
}
```
