Sending valid JSON for Oauth but getting “Username field ”user.id“ not found in data” response

#1

I’m setting a custom Oauth login for RocketChat with the following settings:

URL: http://home.newtonproject.beta.diynova.com
Token Path: /oauth2/access_token/
Token sent via: Header
Identify token sent via: Same as "token sent via"
Identity path: /oauth2/profile/
Authorize path: /oauth2/authorize/
Scope: read
Id: 5e024aac8f78c76a9faf
Secret: 4bf7ae8ad3a7db8c7c7ce27a3bb421bc85b1d7d8
Login style: Popup
Username field: user.email
Merge users: False

Upon clicking the ‘Sign in with Oauth’ button that appears on RocketChat login screen, our server accepts the request and authorizes use of the user’s details. It sends the following JSON:

data = {
"user": {
	"username:": access_token_obj_user,email.replace('@', '_'),
	"id":  access_token_obj_user,email.replace('@', '_'),
	"email": access_token_obj_user,email,
	},
"username:": access_token_obj_user,email.replace('@', '_'),
"id":  access_token_obj_user,email.replace('@', '_'),
"email": access_token_obj_user,email,
}

After that I just get a red popup on the login screen saying “Username field “user.id” not found in data”

Log Contents

Exception while invoking method ‘login’ Error: Service data for service newtonwebsite must include id at AccountsServer.updateOrCreateUserFromExternalService (packages/accounts-base/accounts_server.js:1192:13) at AccountsServer.Accounts.updateOrCreateUserFromExternalService (packages/rocketchat:custom-oauth/server/custom_oauth_server.js:342:47) at AccountsServer.Accounts.updateOrCreateUserFromExternalService (server/configuration/accounts_meld.js:50:52) at MethodInvocation.Accounts.registerLoginHandler.options (packages/accounts-oauth/oauth_server.js:55:21) at tryLoginMethod (packages/accounts-base/accounts_server.js:460:31) at tryLoginMethod (packages/accounts-base/accounts_server.js:1294:14) at AccountsServer._runLoginHandlers (packages/accounts-base/accounts_server.js:458:22) at AccountsServer.Accounts._runLoginHandlers (packages/rocketchat:lib/server/lib/loginErrorMessageOverride.js:7:35) at MethodInvocation.methods.login (packages/accounts-base/accounts_server.js:518:31) at MethodInvocation.methodMap.(anonymous function) (packages/rocketchat_monitoring.js:2731:30) at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1767:12) at DDP._CurrentMethodInvocation.withValue (packages/ddp-server/livedata_server.js:719:19) at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1304:12) at DDPServer._CurrentWriteFence.withValue (packages/ddp-server/livedata_server.js:717:46) at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1304:12) at Promise (packages/ddp-server/livedata_server.js:715:46) at new Promise () at Session.method (packages/ddp-server/livedata_server.js:689:23) at packages/ddp-server/livedata_server.js:559:43

As you can see from the JSON code above, we’re definitely sending the user.id in the JSON.

We’ve tried changing the JSON field and corresponding reference in RocketChat’s settings. But then it just says ‘Internal server error’

Expected end result is a successful oauth login

0 Likes