{"id":20482173,"url":"https://github.com/leaonline/ddp-login","last_synced_at":"2026-02-12T08:08:39.012Z","repository":{"id":113208832,"uuid":"215080042","full_name":"leaonline/ddp-login","owner":"leaonline","description":"Provide loginWithLea to a DDP connection.","archived":false,"fork":false,"pushed_at":"2024-09-03T11:02:15.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-16T04:14:18.709Z","etag":null,"topics":["connection","ddp","meteor","microservices","oauth2"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/leaonline.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-14T15:32:09.000Z","updated_at":"2024-09-03T11:02:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"d5f314be-ab48-47e6-a7df-14d8d1e2be45","html_url":"https://github.com/leaonline/ddp-login","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leaonline%2Fddp-login","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leaonline%2Fddp-login/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leaonline%2Fddp-login/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leaonline%2Fddp-login/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leaonline","download_url":"https://codeload.github.com/leaonline/ddp-login/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242058084,"owners_count":20065062,"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","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":["connection","ddp","meteor","microservices","oauth2"],"created_at":"2024-11-15T16:11:53.409Z","updated_at":"2026-02-12T08:08:33.991Z","avatar_url":"https://github.com/leaonline.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DDP Login\n\nProvides `loginWithLea` to a DDP connection. Requires custom Oauth2 server.\nIsomorphic, handles server-side remote connections, too.\n\n## Installation and usage\n\nInstall via `meteor add leaonline:ddp-connection` and use as the following:\n\n### Server example\n\nYou need a valid lea user account. See [leaonline-accounts]()\nfor how it works.\n\nIf you connect within a Meteor method, you can get the userId via `this.userId` \n\n```javascript\nimport { DDP } from 'meteor/ddp-client'\n\nconst log = (...args) =\u003e console.log('[DDP]:', ...args) \n\nDDP.onReconnect(function (connection) {\n  log('connected to', connection._stream.endpoint)\n  \n  const user = Meteor.users.findOne(userId) // get the userId your way\n  const { accessToken } = user.services.lea\n  \n  DDP.loginWithLea(connection, { accessToken }, function(error, result) {\n    if (error) {\n      log('error - ', error.name, error.message)\n    }\n    \n    if (result) {\n      log('logged in')\n      // run authentication-requiring contexts\n    }\n  })\n})\n\n\nDDP.connect('http://localhost:8080') // some external Meteor app running on 8080\n```\n\n### Client example\n\nOn the client you need a way to retrieve the `accessToken` from the server:\n\n```javascript\nMeteor.methods({\n  getToken: function() {\n    const { userId } = this\n    const user = Meteor.users.findOne(userId)\n    \n    return {\n      accessToken: user?.services?.lea?.accessToken\n    }\n  }\n})\n```\n\n```javascript\nimport { DDP } from 'meteor/ddp-client'\n\nconst log = (...args) =\u003e console.log('[DDP]:', ...args)\n\nDDP.onReconnect(function (connection) {\n  log('connected to', connection._stream.endpoint)\n\n  Meteor.call('getToken', (error, { accessToken }) =\u003e {\n    if (error) return log('error - ', error.name, error.message)\n\n    DDP.loginWithLea(connection, { accessToken }, function (error, result) {\n      if (error) {\n        log('error - ', error.name, error.message)\n      }\n\n      if (result) {\n        log('logged in')\n        // run authentication-requiring contexts\n      }\n    })\n  })\n})\n\nDDP.connect('http://localhost:8080') // some external Meteor app running on 8080\n```\n\n\nYou can also call the functions without a callback, which makes them return \nPromises.\n\n## License\n\nMIT, see [license file](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleaonline%2Fddp-login","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleaonline%2Fddp-login","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleaonline%2Fddp-login/lists"}