The project is in a healthy, maintained state
Allows your application to integrate with Rocket Chat through their "Third-party login" feature.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

Runtime

 Project Readme

OmniAuth Rocket Chat OAuth2 Strategy

Gem Version License: MIT Contributor Covenant

Unofficial OmniAuth strategy to authenticate with Rocket Chat through OAuth2 in OmniAuth.

Installation

Add this line to your application's Gemfile:

gem 'omniauth-rocketchat'

Then execute bundle install.

Rocket Chat Setup

You need to register your application with your Rocket Chat instance to obtain the Client ID and Client Secret. You will also need to add this applications host(s). This whitelists your application for the callback redirect. You can do this by following the steps below:

  • Go to your Rocket Chat instance and login as an administrator.
  • Go to Administration -> Third-party login.
  • Click on New Application.
    • Check the Active checkbox.
    • Fill in the Application Name and Redirect URL. The redirect URL for devise looks like https://example.com/users/auth/rocketchat/callback. You can add multiple hosts by separating them with a comma.
    • Click on Save.
  • Select the third-party login you just created.
    • Copy the Client ID and Client Secret.

Integration

Pick one of the following methods to integrate the strategy with your application.

Basic Usage

use OmniAuth::Builder do
  provider :rocketchat,
  ENV["ROCKETCHAT_CLIENT_ID"],
  ENV["ROCKETCHAT_CLIENT_SECRET"],
  client_options: {
    site: "https://example.com"
  }
end

With Custom Endpoints

use OmniAuth::Builder do
  provider :rocketchat,
  ENV["ROCKETCHAT_CLIENT_ID"],
  ENV["ROCKETCHAT_CLIENT_SECRET"],
  client_options: {
    site: "https://example.com",
    authorize_url: "/custom/oauth/authorize",
    token_url: "/custom/oauth/token"
  }
end

In Rails

# config/initializers/rocketchat.rb
Rails.application.config.middleware.use OmniAuth::Builder do
  provider :rocketchat,
  ENV["ROCKETCHAT_CLIENT_ID"],
  ENV["ROCKETCHAT_CLIENT_SECRET"],
  client_options: {
    site: "https://example.com"
  }
end

With Devise

# config/initializers/rocketchat.rb
Devise.setup do |config|
  config.omniauth :rocketchat,
  ENV["ROCKETCHAT_CLIENT_ID"],
  ENV["ROCKETCHAT_CLIENT_SECRET"],
  client_options: {
    site: "https://example.com"
  }
end

Configuration

  • The client_options options: authorize_url and token_url are optional and default to /oauth/authorize and /oauth/token respectively.
  • scope has no effect on Rocket Chat. Users grant you full permissions to their account. Handle responsibly!

Versioning

This library aims to adhere to Semantic Versioning 2.0.0. Violations of this scheme should be reported as bugs.

Contributing

This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Bug reports and pull requests are welcome on the GitHub project page.

License

Copyright © 2024-2025 David Uhlig. See LICENSE for details.