{"id":31923090,"url":"https://github.com/rocketchat/rocketchat-oauth2-server","last_synced_at":"2025-10-13T23:44:02.379Z","repository":{"id":3246418,"uuid":"48859068","full_name":"RocketChat/rocketchat-oauth2-server","owner":"RocketChat","description":"OAuth 2 Server package","archived":false,"fork":false,"pushed_at":"2022-11-08T07:20:40.000Z","size":24,"stargazers_count":32,"open_issues_count":8,"forks_count":27,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-05-01T11:29:38.226Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RocketChat.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-31T18:43:28.000Z","updated_at":"2023-12-19T12:28:29.000Z","dependencies_parsed_at":"2023-01-11T16:16:28.386Z","dependency_job_id":null,"html_url":"https://github.com/RocketChat/rocketchat-oauth2-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RocketChat/rocketchat-oauth2-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RocketChat%2Frocketchat-oauth2-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RocketChat%2Frocketchat-oauth2-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RocketChat%2Frocketchat-oauth2-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RocketChat%2Frocketchat-oauth2-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RocketChat","download_url":"https://codeload.github.com/RocketChat/rocketchat-oauth2-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RocketChat%2Frocketchat-oauth2-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017231,"owners_count":26086016,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-13T23:43:57.149Z","updated_at":"2025-10-13T23:44:02.375Z","avatar_url":"https://github.com/RocketChat.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# oauth2-server\n\nThis package is a implementation of the package [node-oauth2-server](https://github.com/thomseddon/node-oauth2-server) for Meteor.\n\nIt implements the `authorization_code` and works like the Facebook's OAuth popup.\n\n## Install\n```\nmeteor add rocketchat:oauth2-server\n```\n\n## Implementation\n\n### Server implementation\n * Initialize the lib\n * Add routes to the default router\n * Implement an authenticated route\n\n`server/oauth2server.js`\n```javascript\nvar oauth2server = new OAuth2Server({\n  // You can change the collection names, the values\n  // below are the default values.\n  accessTokensCollectionName: 'oauth_access_tokens',\n  refreshTokensCollectionName: 'oauth_refresh_tokens',\n  clientsCollectionName: 'oauth_clients',\n  authCodesCollectionName: 'oauth_auth_codes',\n  // You can pass the collection object too\n  // accessTokensCollection: new Meteor.Collection('custom_oauth_access_tokens'),\n  // refreshTokensCollection: new Meteor.Collection('custom_oauth_refresh_tokens'),\n  // clientsCollection: new Meteor.Collection('custom_oauth_clients'),\n  // authCodesCollection: new Meteor.Collection('custom_oauth_auth_codes'),\n  // You can enable some logs too\n  debug: true\n});\n\n// Add the express routes of OAuth before the Meteor routes\nWebApp.rawConnectHandlers.use(oauth2server.app);\n\n// Add a route to return account information\noauth2server.routes.get('/account', oauth2server.oauth.authorise(), function(req, res, next) {\n  var user = Meteor.users.findOne(req.user.id);\n\n  res.send({\n    id: user._id,\n    name: user.name\n  });\n});\n```\n\n### Client/Pupup implementation\n\n`client/authorize.js`\n```javascript\n// Define the route to render the popup view\nFlowRouter.route('/oauth/authorize', {\n  action: function(params, queryParams) {\n    BlazeLayout.render('authorize', queryParams);\n  }\n});\n\n// Subscribe the list of already authorized clients\n// to auto accept\nTemplate.authorize.onCreated(function() {\n  this.subscribe('authorizedOAuth');\n});\n\n// Get the login token to pass to oauth\n// This is the best way to identify the logged user\nTemplate.authorize.helpers({\n  getToken: function() {\n    return localStorage.getItem('Meteor.loginToken');\n  }\n});\n\n// Auto click the submit/accept button if user already\n// accepted this client\nTemplate.authorize.onRendered(function() {\n  var data = this.data;\n  this.autorun(function(c) {\n    var user = Meteor.user();\n    if (user \u0026\u0026 user.oauth \u0026\u0026 user.oauth.authorizedClients \u0026\u0026 user.oauth.authorizedClients.indexOf(data.client_id()) \u003e -1) {\n      c.stop();\n      $('button').click();\n    }\n  });\n});\n```\n\n`client/authorize.html`\n```html\n\u003ctemplate name=\"authorize\"\u003e\n  {{#if currentUser}}\n    \u003cform method=\"post\" action=\"\" role=\"form\" class=\"{{#unless Template.subscriptionsReady}}hidden{{/unless}}\"\u003e\n      \u003ch2\u003eAuthorise\u003c/h2\u003e\n      \u003cinput type=\"hidden\" name=\"allow\" value=\"yes\"\u003e\n      \u003cinput type=\"hidden\" name=\"token\" value=\"{{getToken}}\"\u003e\n      \u003cinput type=\"hidden\" name=\"client_id\" value=\"{{client_id}}\"\u003e\n      \u003cinput type=\"hidden\" name=\"redirect_uri\" value=\"{{redirect_uri}}\"\u003e\n      \u003cinput type=\"hidden\" name=\"response_type\" value=\"code\"\u003e\n      \u003cbutton type=\"submit\"\u003eAuthorise\u003c/button\u003e\n    \u003c/form\u003e\n    {{#unless Template.subscriptionsReady}}\n      loading...\n    {{/unless}}\n  {{else}}\n    {{\u003e loginButtons}}\n  {{/if}}\n\u003c/template\u003e\n```\n\n`client/style.css`\n```css\n.hidden {\n  display: none;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frocketchat%2Frocketchat-oauth2-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frocketchat%2Frocketchat-oauth2-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frocketchat%2Frocketchat-oauth2-server/lists"}