# OAuth2 integration with Drupal

**URL:** https://meta.discourse.org/t/oauth2-integration-with-drupal/43652
**Category:** SSO
**Tags:** oauth2
**Created:** [May 4, 2016, 4:08am UTC](https://meta.discourse.org/t/oauth2-integration-with-drupal/43652 "2016-05-04T04:08:47Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![tarek](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tarek/32/124831_2.png) [@tarek](https://meta.discourse.org/u/tarek)
#### Post date: [May 4, 2016, 4:08am UTC](https://meta.discourse.org/t/oauth2-integration-with-drupal/43652/1 "2016-05-04T04:08:47Z")

</div>

**Special thanks to @dashohoxha for his help!!**

Continuing the discussion from [OAuth2 Basic Support](https://meta.discourse.org/t/oauth2-basic-support/33879/59):

I will use this thread to document my steps and progress in integrating Discourse and Drupal via OAuth2.

At present, the status of my implementation is **WORKING**.

**Installation on Discourse** :  
For installation on Discourse, do the following:

1. Install [OAuth2 Basic plugin](https://github.com/discourse/discourse-oauth2-basic) as per [this thread](https://meta.discourse.org/t/oauth2-basic-support). See [Install a plugin](https://meta.discourse.org/t/install-a-plugin/19157) for details on how to install a plugin

2. Configure OAuth2 plugin:

- You should see an “OAuth2” section in “Login” in Settings when logged in as an administrative user.
- Enable “Custom OAuth2 is enabled”
- Set client ID as “discourse”.
- Create a client secret that is a random series of letters and numbers. You can use `apg -a 0 -m 20` to generate one.
- **oauth2 authorize url** : `https://DRUPAL/oauth2/authorize` where DRUPAL = your Drupal site’s base URL
- **oauth2 token url** : `https://DRUPAL/oauth2/token`
- **oauth2 user json url** : `https://DRUPAL/oauth2/user_profile.json`
- **oauth2 json user id path** : `uid`
- **oauth2 json username** : `name`
- **oauth2 json name path** :[You can leave this blank]
- **oauth2 json email path** : `mail`
- **oauth2 email verified** : [Check this on]

When you hit ‘login’, you should now see a ‘login with OAuth2’ option.

**Installation on Drupal**

1. Install the following plugins:

- [OAuth2 Login Provider](https://www.drupal.org/project/oauth2_loginprovider)
- [OAuth2 Server](https://www.drupal.org/project/oauth2_server)
- [Services](https://www.drupal.org/project/services)
- [REST Server](https://www.drupal.org/project/rest_server)

1. Add client at `/oauth2-servers/manage/oauth2/clients`

- Call the client `discourse`
- Enter the same client secret as above
- Set **Redirect URIs** as `http://DISCOURSE/auth/oauth2_basic/callback` where DISCOURSE = your discourse forum’s base URL

**Status and Known Issues** :  
If you follow the steps above, you should see a “with OAuth2” badge on the login screen. Clicking on it should redirect you to your Drupal site for login that asks “Authorize discourse to use your account?” Clicking “Yes” results in either association to an existing account with the same email or creation of a new account with that email.

**STATUS: WORKING**

**KNOWN ISSUES:**

- Must be authorized with each login.
- Does not honour ‘groups’ / ‘roles’

tarek : )

---

_[View the full topic](https://meta.discourse.org/t/oauth2-integration-with-drupal/43652)._
