<a id="x-oauth-2"></a>

# X OAuth 2

<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                                          |
|------------------|-----------------------------------------------------|
| `twitter-oauth2` | `social_core.backends.twitter_oauth2.TwitterOAuth2` |

Twitter offers per application keys named `Client ID` and `Client Secret`.
To enable Twitter these two keys are needed. Further documentation at
[Twitter development resources](https://developer.twitter.com/en/docs/authentication/oauth-2-0/authorization-code):

- Register a new application at [Twitter App Creation](https://developer.twitter.com/en/portal/dashboard),
- Fill **Client ID** and **Client Secret** values:
  ```default
  SOCIAL_AUTH_TWITTER_OAUTH2_KEY = ''
  SOCIAL_AUTH_TWITTER_OAUTH2_SECRET = ''
  ```
- You can specify PKCE challenge method following:
  ```default
  SOCIAL_AUTH_TWITTER_OAUTH2_PKCE_CODE_CHALLENGE_METHOD = ''
  ```

  The possible values for configuration are `s256` and `plain`.
  By default, `s256` is set.

  You can see more information about PKCE at [RFC7636](https://datatracker.ietf.org/doc/html/rfc7636).
- You need to specify an URL callback or the OAuth will raise a “403 Client Error”.
  The callback URL should be something like “[https://example.com/complete/twitter-oauth2](https://example.com/complete/twitter-oauth2)”
