{"id":13398489,"url":"https://github.com/nicolaslopezj/meteor-apollo-accounts","last_synced_at":"2025-04-13T01:27:37.394Z","repository":{"id":57295794,"uuid":"71171397","full_name":"nicolaslopezj/meteor-apollo-accounts","owner":"nicolaslopezj","description":"Meteor accounts in GraphQL","archived":false,"fork":false,"pushed_at":"2019-04-08T08:06:36.000Z","size":1340,"stargazers_count":146,"open_issues_count":38,"forks_count":37,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-08-20T13:02:22.975Z","etag":null,"topics":["accounts","apollo","authentication","graphql","javascript","meteor","react"],"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/nicolaslopezj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-17T19:01:54.000Z","updated_at":"2024-08-20T13:02:22.976Z","dependencies_parsed_at":"2022-08-30T22:31:08.352Z","dependency_job_id":null,"html_url":"https://github.com/nicolaslopezj/meteor-apollo-accounts","commit_stats":null,"previous_names":["orionsoft/meteor-apollo-accounts"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolaslopezj%2Fmeteor-apollo-accounts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolaslopezj%2Fmeteor-apollo-accounts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolaslopezj%2Fmeteor-apollo-accounts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolaslopezj%2Fmeteor-apollo-accounts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicolaslopezj","download_url":"https://codeload.github.com/nicolaslopezj/meteor-apollo-accounts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245223464,"owners_count":20580354,"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":["accounts","apollo","authentication","graphql","javascript","meteor","react"],"created_at":"2024-07-30T19:00:27.387Z","updated_at":"2025-03-26T19:12:09.314Z","avatar_url":"https://github.com/nicolaslopezj.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Meteor Apollo Accounts\n\nA implementation of Meteor Accounts only in GraphQL with Apollo.\n\nThis package uses the Meteor Accounts methods in GraphQL, it's compatible with the accounts you have saved in your database and you may use apollo-accounts and Meteor's DPP accounts at the same time.\n\n\u003e Project sponsored by [Orion Hosting](https://orion.hosting/?utm_source=github-apollo-accounts) - Hosting for Meteor\n\n## Installing\n\n### Install on Meteor server\n\n```sh\nmeteor add nicolaslopezj:apollo-accounts\nyarn add graphql-loader\n```\n\nInitialize the package.\n\n```js\nimport {makeExecutableSchema} from 'graphql-tools'\nimport {loadSchema, getSchema} from 'graphql-loader'\nimport {initAccounts} from 'meteor/nicolaslopezj:apollo-accounts'\nimport typeDefs from './schema'\nimport resolvers from './resolvers'\n\n// Load all accounts related resolvers and type definitions into graphql-loader\ninitAccounts({\n  loginWithFacebook: false,\n  loginWithGoogle: false,\n  loginWithLinkedIn: false,\n  loginWithPassword: true\n})\n\n// Load all your resolvers and type definitions into graphql-loader\nloadSchema({typeDefs, resolvers})\n\n// Gets all the resolvers and type definitions loaded in graphql-loader\nconst schema = getSchema()\nconst executableSchema = makeExecutableSchema(schema)\n```\n\n\n### Install on your apollo app\n\nMay or may not be the same app.\n\n```sh\nnpm install meteor-apollo-accounts\n```\n\n## Examples\n\n- [janikvonrotz/meteor-apollo-accounts-example](https://github.com/janikvonrotz/meteor-apollo-accounts-example): Meteor client and server side.\n- [orionsoft/server-boilerplate](https://github.com/orionsoft/server-boilerplate): Large Meteor server side only starter app.\n\n## Tutorials\n- [Using Meteor With Apollo and React](https://blog.orionsoft.io/using-meteor-accounts-with-apollo-and-react-df3c89b46b17#.znozw2zbd)\n\n## Methods\n\nMeteor accounts methods, client side only. All methods are promises.\n\n#### loginWithPassword\n\nLog the user in with a password.\n\n```js\nimport { loginWithPassword } from 'meteor-apollo-accounts'\n\nloginWithPassword({username, email, password}, apollo)\n```\n\n- ```username```: Optional. The user's username.\n\n- ```email```: Optional. The user's email.\n\n- ```password```: The user's password. The library will hash the string before it sends it to the server.\n\n- ```apollo```: Apollo client instance.\n\n#### changePassword\n\nChange the current user's password. Must be logged in.\n\n```js\nimport { changePassword } from 'meteor-apollo-accounts'\n\nchangePassword({oldPassword, newPassword}, apollo)\n```\n\n- ```oldPassword```: The user's current password. This is not sent in plain text over the wire.\n\n- ```newPassword```: A new password for the user. This is not sent in plain text over the wire.\n\n- ```apollo```: Apollo client instance.\n\n#### logout\n\nLog the user out.\n\n```js\nimport { logout } from 'meteor-apollo-accounts'\n\nlogout(apollo)\n```\n\n- ```apollo```: Apollo client instance.\n\n#### createUser\n\nCreate a new user.\n\n```js\nimport { createUser } from 'meteor-apollo-accounts'\n\ncreateUser({username, email, password, profile}, apollo)\n```\n\n- ```username```: A unique name for this user.\n\n- ```email```: The user's email address.\n\n- ```password```: The user's password. This is not sent in plain text over the wire.\n\n- ```profile```: The profile object based on the ```UserProfileInput``` input type.\n\n- ```apollo```: Apollo client instance.\n\n#### verifyEmail\n\nMarks the user's email address as verified. Logs the user in afterwards.\n\n```js\nimport { verifyEmail } from 'meteor-apollo-accounts'\n\nverifyEmail({token}, apollo)\n```\n\n- ```token```: The token retrieved from the verification URL.\n\n- ```apollo```: Apollo client instance.\n\n\n#### forgotPassword\n\nRequest a forgot password email.\n\n```js\nimport { forgotPassword } from 'meteor-apollo-accounts'\n\nforgotPassword({email}, apollo)\n```\n\n- ```email```: The email address to send a password reset link.\n\n- ```apollo```: Apollo client instance.\n\n#### resetPassword\n\nReset the password for a user using a token received in email. Logs the user in afterwards.\n\n```js\nimport { resetPassword } from 'meteor-apollo-accounts'\n\nresetPassword({newPassword, token}, apollo)\n```\n\n- ```newPassword```: A new password for the user. This is not sent in plain text over the wire.\n\n- ```token```: The token retrieved from the reset password URL.\n\n- ```apollo```: Apollo client instance.\n\n\n#### loginWithFacebook\n\nLogins the user with a facebook accessToken\n\n```js\nimport { loginWithFacebook } from 'meteor-apollo-accounts'\n\nloginWithFacebook({accessToken}, apollo)\n```\n\n- ```accessToken```: A Facebook accessToken. It's recommended to use\nhttps://github.com/keppelen/react-facebook-login to fetch the accessToken.\n\n- ```apollo```: Apollo client instance.\n\n#### loginWithGoogle\n\nLogins the user with a google accessToken\n\n```js\nimport { loginWithGoogle } from 'meteor-apollo-accounts'\n\nloginWithGoogle({accessToken}, apollo)\n```\n\n- ```accessToken```: A Google accessToken. It's recommended to use\nhttps://github.com/anthonyjgrove/react-google-login to fetch the accessToken.\n\n- ```apollo```: Apollo client instance.\n\n\n#### onTokenChange\n\nRegister a function to be called when a user is logged in or out.\n\n```js\nimport { onTokenChange } from 'meteor-apollo-accounts'\n\nonTokenChange(function () {\n  console.log('token did change')\n  apollo.resetStore()\n})\n```\n\n#### userId\n\nReturns the id of the logged in user.\n\n```js\nimport { userId } from 'meteor-apollo-accounts'\n\nasync function () {\n  console.log('The user id is:', await userId())\n}\n\n```\n\n\n### React-Native usage\n\n```js\n\n//First you'll need to import the Storage library that you'll use to store the user details (userId, tokens...),\n// AsyncStorage is highly recommended.\n\nimport {\n  ...\n  AsyncStorage\n} from 'react-native';\n\nimport { loginWithPassword, userId, setTokenStore} from 'meteor-apollo-accounts'\n\n// Then you'll have to define a TokenStore for your user data using setTokenStore\n// (for instance when your component is mounted):\nsetTokenStore({\n  set: async function ({userId, token, tokenExpires}) {\n    await AsyncStorage.setItem('Meteor.userId', userId)\n    await AsyncStorage.setItem('Meteor.loginToken', token)\n    // AsyncStorage doesn't support Date type so we'll store it as a String\n    await AsyncStorage.setItem('Meteor.loginTokenExpires', tokenExpires.toString())\n  },\n  get: async function () {\n    return {\n      userId: await AsyncStorage.getItem('Meteor.userId'),\n      token: await AsyncStorage.getItem('Meteor.loginToken'),\n      tokenExpires: await AsyncStorage.getItem('Meteor.loginTokenExpires')\n    }\n  }\n})\n\n// Finally, you'll be able to use asynchronously any method from the library:\nasync login (event) {\n  event.preventDefault();\n\n  try {\n    const id_ = await loginWithPassword({ \"email\", \"password\" }, this.client)\n    this.client.resetStore()\n  } catch (error) {\n\n  }\n}\n\n```\n\n\n\n## Contributors\n\n- [@nicolaslopezj](https://github.com/nicolaslopezj)\n- [@janikvonrotz](https://github.com/janikvonrotz)\n- [@dbrrt](https://github.com/dbrrt)\n- [@hammadj](https://github.com/hammadj)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicolaslopezj%2Fmeteor-apollo-accounts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicolaslopezj%2Fmeteor-apollo-accounts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicolaslopezj%2Fmeteor-apollo-accounts/lists"}