Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does it supports OAUTH2 mechanism? #393

Closed
prashant-kahalkar-bh opened this issue Jan 18, 2023 · 2 comments
Closed

Does it supports OAUTH2 mechanism? #393

prashant-kahalkar-bh opened this issue Jan 18, 2023 · 2 comments

Comments

@prashant-kahalkar-bh
Copy link

prashant-kahalkar-bh commented Jan 18, 2023

Hi I am new to js and I am using rhea lib to connect to solace broker and publish/subscribe on broker topic/queues using Basic auth, however instead of basic auth I want to use OAuth2 for authentication purpose. I tried same but it didn't work. I get the Authentication error - 'ConnectionError: Failed to authenticate: 2'. As per solace document, they support AMQP with OAUTH - https://docs.solace.com/Security/Client-Authentication-Overview.htm#OAuth 'For AMQP clients, PubSub+ event brokers support the XOAUTH2 SASL authentication mechanism. In this case, the AMQP URL must be amqps://:?amqp.saslMechanisms=XOAUTH2.' however for rhea lib, adding saslMechanisms in hostname isn't supported. We have to give saslMechanisms in container options, and provide the token in 'password' field as per Solace doc. I did the same thing but it didn't work.
Note: I already have enabled OAuth in my solace broker and currently using it with MQTT protocol.

const options: ContainerOptions = {
scheme: 'amqps',
host: 'localhost',
port: 5671,
username: 'devuser',
password: token.access_token,
id: 'testclient',
transport: 'tls',
ca: [fs.readFileSync(path.resolve(__dirname + "../..", 'certificate.pem'))],
sasl: {enabled:true},
container_id: "testcontId",
sasl_mechanism: ["XOAUTH2"]
}
this.container = create_container(options);
this.connection = this.container.connect(options);

@grs
Copy link
Member

grs commented Jan 18, 2023

Use token for the token instead of password

@prashant-kahalkar-bh
Copy link
Author

prashant-kahalkar-bh commented Jan 18, 2023

Use token for the token instead of password

Thank you @grs it worked! :)

const options: ContainerOptions = {
host: 'localhost',
port: 5671,
username: 'devuser',
token: token.access_token,
id: 'testclient',
transport: 'tls',
ca: [fs.readFileSync(path.resolve(__dirname + "../..", 'certificate.pem'))],
sasl: {enabled:true},
container_id: "testcontId",
sasl_mechanism: ["XOAUTH2"]
}
this.container = create_container(options);
this.connection = this.container.connect(options);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants