Cant get oauth2 working with Drupal 8

Description

I have a Drupal 8 and Rocket.chat integrated. I can show rocket.chat channels inside a Drupal 8.
I want to use oauth2 to authenticate Drupal8 registered users to my rocket.chat local server.

I have installed Drupal 8 Simple oauth module https://www.drupal.org/project/simple_oauth
And I think I have set it up correctly.

In the rocket.chat server, in OAUTH section, there is a Drupal block.
In that there are two fields: “Drupal oAuth2 Client ID” and “Drupal oAuth2 Client Secret”
Where should I get these, the Drupal 8 oauth2 module shows only a UUID but no secret anywhere ?

Or which Drupal 8 module should I use to achieve this to work, maybe this “simple_oauth” module is not good with rocket.chat? Or is there a module at all to make oauth2 work with Drupal 8 ?

Server Setup Information

  • Version of Rocket.Chat Server: 3.6.1
  • Operating System:
  • Deployment Method:
  • Number of Running Instances: 1
  • DB Replicaset Oplog:
  • NodeJS Version: 12.14.0
  • MongoDB Version: 4.4.1
  • Proxy:
  • Firewalls involved: none

Alright, now I added a custom oauth.

What should I add in the field " Identity path" ?

My rocketchat logs are showing this error:
“line”:“403”,“file”:“oauth_server.js”,“message”:“Error in OAuth Server: Failed to fetch identity from drupal8 at https://mysite.com. Unexpected token < in JSON at position 0”,“time”:

I have tried there “/user” or “/userinfo” etc. but none of them works…

This doesn’t directly answer your question, but it may help.

I did this successfully in D7 using the oauth2_server module, which includes OpenID Connect support. The D8 version of that module is still in Beta, but development appears pretty active. The endpoint in the D7 version is oauth2/UserInfo.

Hi
Thanks, I will try it with the current D8 module, maybe it has the same endpoint. Also I would like to know for which version of Drupal is that Rocket.Chat oAuth “drupal” tab there, which is there as default. Maybe the Rocket.Chat devs knows for which version it is, and which Drupal module should be used.

EDIT: Drupal 8 module does not have that URL.
Byt the way, where do you need that OpenID Connect? I can understand that it is needed if you want to login to your D8 with Facebook etc, but now the D8 gives authorization to Rocket.chat

I guess rocketchat just works only with Drupal 7, or I just dont know how to use the modules

I took a quick look at the D8 code, since I’m going to have to deal with converting before too long. Oauth2_server 2.0 does define /oauth2/UserInfo as an endpoint in oauth2_server.routing.yml, so you may have a configuration issue.

It took me forever to get everything working, by the way, so I can sympathize. In case it helps, here are some of the settings in my R.C custom oauth setup.

Token path: /oauth2/token
Identity path: /oauth2/UserInfo
Authorize path: /oauth2/authorize
Scope: openid email basic offline_access profile

Hi,
Thanks for your reply. I was also able to get this working. I was trying first with wrong module (simple oauth2), and also didn’t know that openid should be as the scope.

Hello @anaconda111 , can you please tell me how you did it? I have the same problem.

Hello, @jason can you tell me how you achieved this? I’ve been struggling for a few days. I still haven’t found a solution…

Hello, @ jason can you tell me

Please don’t keep trying to @ people. People will reply if they can.

Also note that this thread is several months old.

You may be better off starting a new one with a proper description of your setup and what you have done so far and what your error is.