Continuing the discussion from OAuth2 Basic Support:
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 NOT WORKING. The error is that the callback appears to fail with a blank screen.
Installation on Discourse:
For installation on Discourse, do the following:
Install OAuth2 Basic plugin as per this thread. See Install a plugin for details on how to install a plugin
-
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.
- Set oauth2 authorize url:
https://DRUPAL/oauth2/authorize
where DRUPAL = your Drupal site's base URL
- Set oauth2 token url:
https://DRUPAL/oauth2/token
- Set oauth2 user json url:
https://DRUPAL/oauth2/user/profile
- Leave other fields blank and save all fields.
When you hit 'login', you should now see a 'login with OAuth2' option.
Installation on Drupal
- Install the following plugins:
-
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:
a blank page with the following link: http://DISCOURSE/auth/oauth2_basic/callback?code=9n55b3b96abd08e31b80cd5ar08ad49eb38a6e40&state=2a0586dfa2d0bb492ed8761dc999fec5cf7a0e604adcgc92
If this page is reloaded, the following error is given:
Sorry, there was an error authorizing your account. Perhaps you did not approve authorization?
In DISCOURSE logs, the following error appears:
OpenURI::HTTPError (404 Not found : Could not find the controller.)
/usr/local/lib/ruby/2.0.0/open-uri.rb:353:in 'open_http'
In the DRUPAL system's apache logs, the following error appears:
DRUPAL x.x.x.x - - [04/May/2016:00:19:42 -0000] "GET /oauth2/user/profile HTTP/1.1" 404 4382 "-" "Ruby"
I will keep this posted as I get closer to a solution!
I have filed a related bug regarding the callback 404 with the hopes of some clarification from the module developers.
tarek : )