Wordpress OAuth 3.1.96: Unable to Authenticate
Your Rocket.Chat version: 0.25.0
I'm having trouble authenticating using the Wordpress OAuth Server plugin, v3.1.96. I've been following the information in #747 but am still striking issues. I don't know if this is because the WP OAuth Server is now a later version that the one tested in the instructions.
On the WP side:
- I've added
$me_data['id'] = $me_data['ID'];to the filters.php file and uploaded a plugin zip with this change. - I also tried adding the code from the Gist to functions.php, but outcomes are the same.
- I've checked all the Grant Types in the Advanced Configuration menu.
- I've double and triple checked my Client ID and secret between WP and my RC instance.
- I'm positive I've added the default RC redirect URL to the WP Client Details dialogue and saved it.

Scenario 1
- In WP under Advanced Settings / Misc Settings I have "Require Exact Redirect URI" checked.
When attempting to login, the new window launched from RC and displays the following error:
{"error":"redirect_uri_mismatch","error_description":"The redirect URI provided is missing or does not match","error_uri":"http:\/\/tools.ietf.org\/html\/rfc6749#section-3.1.2"}
Nothing in the RC logs.
Scenario 2
- In WP I have unchecked "Require Exact Redirect URI"
This time I am taken to the WP login form in the pop-up window, where I am able to login. However, after logging in, no re-direct occurs. I am simply shown my WP website content in this pop-up window.
RocketChat has not logged in, in the other window.
Scenario 3
- As per Scenario 2, however I am still logged in to the WP website.
This time, when clicking the WP icon from the RC sign-in page, the pop-up window launches, then closes.
RocketChat shows an "Internal Server Error" message.
RC logs:
I20160408-15:13:43.047(0) at: cl7sculdskpuygnlmll8f9cklmmi0yyleiecfpol W20160408-15:13:43.897(0) (oauth_server.js:398) Error in OAuth Server: Failed to fetch identity from wordpress at http://mywebsiteurl.com/oauth/me. failed [400] {"error":"invalid_request","error_description":"Missing or invalid parameter(s)"} I20160408-15:13:44.077(0) Exception while invoking method 'login' Error: Failed to fetch identity from wordpress at http://mywebsiteurl.com/oauth/me. failed [400] {"error":"invalid_request","error_description":"Missing or invalid parameter(s)"} at CustomOAuth.getIdentity (packages/rocketchat_custom-oauth/custom_oauth_server.coffee:92:16) at Object.handleOauthRequest (packages/rocketchat_custom-oauth/custom_oauth_server.coffee:101:20) at OAuth._requestHandlers.(anonymous function) (packages/oauth2/oauth2_server.js:8:1) at middleware (packages/oauth/oauth_server.js:173:1) at packages/oauth/oauth_server.js:146:1
Scenario 4
- When adding a new Client to the WP OAuth Server, there is a field to input the "Redirect URI:". The default text for this field says, "Leave Blank for Client Credentials." Therefore, in this scenario, I am leaving it blank.
The outcome is the same as Scenarios 2 and 3.
Scenario 5
- The same setup as Scenario 4 with the blank client credentials, however, I am also re-checking the "Require Exact Redirect URI" checkbox under Advanced / Misc settings.
The outcome is the same as Scenarios 2 and 3.
Not sure what other information to provide. Have tested in the latest versions of both Firefox and Chromium.
Any assistance much appreciated.
I installed the older 3.1.7 version and still receive the error:
{"error":"redirect_uri_mismatch","error_description":"The redirect URI provided is missing or does not match","error_uri":"http:\/\/tools.ietf.org\/html\/rfc6749#section-3.1.2"}
The URL in the pop-up login window includes the following:
redirect_uri=http://myrcinstance.com/_oauth/wordpress
This is exactly the same URL I have entered in the "Redirect URI:" field in the WP OAuth Client details screen.
I have followed the instructions in #747 and created a custom RC OAuth entry, just calling it "wordpresscustom". I updated the details in my WP OAuth Client details with the new redirect URI.
This has overcome the "redirect_uri_mismatch" error. The pop-up window presented me with the WP login screen. This is with "Require Exact Redirect URI" checked in the WP OAuth Server settings.
Unfortunately, after logging in, the pop-up did not disappear, rather it just showed me a page of my WP website content.
After closing the pop-up, and clicking the "WP Custom Login" button on my RC login page (this time already logged into WP), I once again see the Internal Server error in the RC logs:
I20160408-20:41:52.431(0) at: 80svsrmoy0fzgn37um89un7xrlcglsv0okgnwyo1 W20160408-20:41:53.215(0) (oauth_server.js:398) Error in OAuth Server: Failed to fetch identity from wordpresscustom at http://mywpwebsite.com/oauth/me. failed [400] {"error":"invalid_request","error_description":"Missing or invalid parameter(s)"} I20160408-20:41:53.385(0) Exception while invoking method 'login' Error: Failed to fetch identity from wordpresscustom at http://mywpwebsite.com/oauth/me. failed [400] {"error":"invalid_request","error_description":"Missing or invalid parameter(s)"} at CustomOAuth.getIdentity (packages/rocketchat_custom-oauth/custom_oauth_server.coffee:92:16) at Object.handleOauthRequest (packages/rocketchat_custom-oauth/custom_oauth_server.coffee:101:20) at OAuth._requestHandlers.(anonymous function) (packages/oauth2/oauth2_server.js:8:1) at middleware (packages/oauth/oauth_server.js:173:1) at packages/oauth/oauth_server.js:146:1
Pretty much the same as Scenario 3 above.
I have successfully setup a GitHub OAuth on my RC instance, just to check that worked. However, I would really like WP to work, as my subscribers already have accounts on my WP site.
Just to be on the safe side here, you guys tried using the built-in Wordpress OAuth, right? meanwhile, I'll try to run a few tests with our demo.
Looking at custom_oauth_server.coffee state: query.state is requested in getAccessToken.
So on the WP side:
- Checking the Enforce State Parameter seemed to work for me.

Following on from above -- I get a Register Username form. Username cannot be read / undefined in log files but is used / set in Wordpress:
Exception while invoking method 'getUsernameSuggestion' TypeError: Cannot read property 'length' of undefined at generateSuggestion (server/methods/getUsernameSuggestion.coffee:27:14) at [object Object].Meteor.methods.getUsernameSuggestion (server/methods/getUsernameSuggestion.coffee:88:10) at [object Object].methodsMap.(anonymous function) (server/lib/debug.js:17:26) at maybeAuditArgumentChecks (livedata_server.js:1698:12) at livedata_server.js:708:19 at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1) at livedata_server.js:706:40 at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1) at livedata_server.js:704:46 at tryCallTwo (/app/.meteor/heroku_build/app/programs/server/npm/promise/node_modules/meteor-promise/node_modules/promise/lib/core.js:45:5)
Did anyone ever get WP Oauth working???
The plugin on WP side has been updated alot and doesn't want to give rocket what it needs I think.
Would someone be willing to send me an older version of the plugin that works? I did pay for a license but the plugin developers haven't been responding to me about this.
I no longer has the old plugin sadly, but something needs to be done to allow easy wordpress user to rocket chat. Oauth, Saml, CAS anything.
es, I tried those steps but I got this error:
{"error":500,"reason":"Internal server error","message":"Internal server error [500]","errorType":"Meteor.Error"}
At sing.li request I will talk about the timeline of going from a semi-working plugin to one that doesn't work and cost money.
The last time I got oauth to work between WP and RC was verison 3.1.98 this was back in june. As time goes on software gets updated and WP updated changing some things around I do believe they changed the way they handle usernames and passwords a little. So the oauth plugin for WP updated to deal with those changes and put a lot of features behind a paywall. So the Oauth plugin no longer provides all the info that RC needs to have a complete checklist at least on the free version the paid version as stated above also does not work but for unknown reasons.
Here is the plugin in question
https://wordpress.org/plugins/oauth2-provider/ https://wp-oauth.com/
also Flantascience here is the older version please tell me if you can get it too work.
https://downloads.wordpress.org/plugin/oauth2-provider.3.1.98.zip
@RocketChat/core We need to consider an "officially supported" way of doing SSO (hopefully without involving a paid plugin on the WP side) with WordPress - as the population of community users integrating Rocket.Chat to their WordPress site is growing daily.
Well I can show you two way that some other have done integration with WP, the forums I use uses this WP plugin
https://wordpress.org/plugins/wp-w3all-phpbb-integration/
my wiki uses this and was by far the easiest and least obtuse way.
https://www.mediawiki.org/wiki/Extension:WPMW
@wargamesqcf Still not working. I may have come across something though. I checked the RocketChat logs and saw this. I added the bold around 'self signed certificate.' I wonder if it is not working since I have a self-signed cert? I set it up specifically for testing purposes. I already paid $60 for the plugin, I guess I didn't want to pay another $60 for an SSL just for testing. Do you think that's the issue?
[34mW20161226-19:35:26.131(0) (oauth_server.js:398) [35mError in OAuth Server: Failed to complete OAuth handshake with wordpresscustomlog at https://forumthing.flimjannery.com/oauth/token. self signed certificate [34mI20161226-19:35:26.344(0) Exception while invoking method 'login' Error: Failed to complete OAuth handshake with wordpresscustomlog at https://forumthing.flimjannery.com/oauth/token. self signed certificate at CustomOAuth.getAccessToken (packages/rocketchat_custom-oauth/custom_oauth_server.coffee:71:16) at Object.handleOauthRequest (packages/rocketchat_custom-oauth/custom_oauth_server.coffee:106:23) at OAuth._requestHandlers.(anonymous function) (packages/oauth2/oauth2_server.js:8:1) at middleware (packages/oauth/oauth_server.js:173:1) at packages/oauth/oauth_server.js:146:1
I also just noticed my Pro license doesn't work on this older version of WPOAuth. Not sure if that is impacting it.
Is there a way to do the reverse? Maybe to log into WordPress using a Meteor account?
I spent a lot of time messing about with this also, and in the end I found it made my life a lot easier to just plug Rocket.Chat, WordPress, and all my other services into https://auth0.com/, rather than randomly elect one of them given that managing accounts is orthogonal to any of their actual purpose in my stack.
My issue is right now WP is already handling accounts for my forums and wiki, don't want to jump over to a 3rd party oauth unless WP can push accounts to that and then back to rocket.
So this actually is working now. It is not exactly what I desired but I think it's what you are after @wargamesqcf
The main thing causing a problem was that I used a self-signed SSL certificate. I got this because I just wanted to test things out. I got a real SSL and it worked. I also maybe did an adjustment on my checkboxes, so let me post what I've got.
The trouble I still had... i actually want the reverse. I was hoping that all my meteor users would be able to login to WordPress with their meteor accounts. This lets them login to Meteor using WordPress.
Here are the settings on WordPress. This is for OAuth Server 3.2. Grant Types - everything checked Misc Settings - token length: 30, check for 'enforce state parameter' Open ID connect - lifetime: 3600 seconds Token Lifetimes - access token: 3600 seconds, Refresh token lifetime: 86400
I am not sure if I had 'enforce state parameter' checked before when I was receiving errors. But it is checked off now and it works.
I also have 'require exact url' UNchecked.
On my RocketChat, I did not use the WordPress OAuth, I created a custom one.
URL: https://peerunschooling.net Token Path: /oauth/token Identity Path: /oauth/me Authorize Path: /oauth/authorize Scope: openid Token Sent Via: Payload Login Style: Popup
My app is at https://members.peerunschooling.net and I was able to successful embed the app as an iframe here: https://peerunschooling.net/chat-app
I just gotta find a way to do the reverse. Or maybe this auth0.com thing is the answer. I would like to keep it simple, this has become more time consuming that I expected.
Just doesn't work on the non-pro verison.