<a id="bitbucket"></a>

# Bitbucket

<a id="backend-class"></a>

## Backend class

For Django, add this class path to `AUTHENTICATION_BACKENDS`. For other
integrations, use the same class path in the framework-specific backend
setting.

| Backend name       | Class path                                       |
|--------------------|--------------------------------------------------|
| `bitbucket-oauth2` | `social_core.backends.bitbucket.BitbucketOAuth2` |

Bitbucket supports both OAuth2 and OAuth1 logins.

1. Register a new OAuth Consumer by following the instructions in the
   Bitbucket documentation: [OAuth on Bitbucket](https://confluence.atlassian.com/display/BITBUCKET/OAuth+on+Bitbucket)

   Note: For OAuth2, your consumer MUST have the “account” scope otherwise
   the user profile information (username, name, etc.) won’t be accessible.
2. Configure the appropriate settings for OAuth2 or OAuth1 (see below).

<a id="oauth2"></a>

## OAuth2

- Fill `Consumer Key` and `Consumer Secret` values in the settings:
  ```default
  SOCIAL_AUTH_BITBUCKET_OAUTH2_KEY = '<your-consumer-key>'
  SOCIAL_AUTH_BITBUCKET_OAUTH2_SECRET = '<your-consumer-secret>'
  ```
- If you would like to restrict access to only users with verified e-mail
  addresses, set `SOCIAL_AUTH_BITBUCKET_OAUTH2_VERIFIED_EMAILS_ONLY = True`
  By default the setting is set to `False` since it’s possible for a
  project to gather this information by other methods.

<a id="oauth1"></a>

## OAuth1

- OAuth1 works similarly to OAuth2, but you must fill in the following settings
  instead:
  ```default
  SOCIAL_AUTH_BITBUCKET_KEY = '<your-consumer-key>'
  SOCIAL_AUTH_BITBUCKET_SECRET = '<your-consumer-secret>'
  ```
- If you would like to restrict access to only users with verified e-mail
  addresses, set `SOCIAL_AUTH_BITBUCKET_VERIFIED_EMAILS_ONLY = True`.
  By default the setting is set to `False` since it’s possible for a
  project to gather this information by other methods.

<a id="user-id"></a>

## User ID

Bitbucket recommends the use of [UUID](https://confluence.atlassian.com/display/BITBUCKET/Use+the+Bitbucket+REST+APIs) as the user identifier instead
of `username` since they can change and impose a security risk. For
that reason `UUID` is used by default, but for backward
compatibility reasons, it’s possible to get the old behavior again by
defining this setting:

```default
SOCIAL_AUTH_BITBUCKET_USERNAME_AS_ID = True
```
