Hi everyone,
I know this question is asked many times but I am currently facing this problem while creating custom authentication
Accounts.registerLoginHandler(function(options) {
if (!options.accessToken) {
return undefined; // don't handle
}
check(options, Match.ObjectIncluding({
serviceName: String,
}));
const service = AccessTokenServices[options.serviceName];
// Skip everything if there's no service set by the oauth middleware
if (!service) {
throw new Error(`Unexpected AccessToken service ${ options.serviceName }`);
}
// Make sure we're configured
if (!ServiceConfiguration.configurations.findOne({ service: service.serviceName })) {
throw new ServiceConfiguration.ConfigError();
}
if (!_.contains(Accounts.oauth.serviceNames(), service.serviceName)) {
// serviceName was not found in the registered services list.
// This could happen because the service never registered itself or
// unregisterService was called on it.
return {
type: 'oauth',
error: new Meteor.Error(
Accounts.LoginCancelledError.numericError,
`No registered oauth service found for: ${ service.serviceName }`
),
};
}
const oauthResult = service.handleAccessTokenRequest(options);
const updated = Accounts.updateOrCreateUserFromExternalService(service.serviceName, oauthResult.serviceData, oauthResult.options);
// updated is returning undefined
});
Now the problem is even though Accounts.oauth.serviceNames()
has my custom service name, when I try to login using curl command it returns
{
"status": "error",
"error": 400,
"message": "Unrecognized options for login request"
}
Servies like github are working fine but custom defined are not working. Please help