Authenticate users in your app using phoneNumber and deviceId and receive a token in return.
- Your app calls the Graphcool mutation
authenticatePhoneUser(phoneNumber: String!, deviceId: String!) - If no user exists yet that corresponds to the passed
phoneNumber, or thedeviceIddoes not match, an error will be returned - If a user with the passed
phoneNumberexists and thedeviceIdmatches, the mutation returns a valid token for the user - Your app stores the token and uses it in its
Authorizationheader for all further requests to Graphcool
- Create a new Schema Extension Function and paste the schema from
schema-extension.graphqland code fromauthenticate.js. - add a PAT to the project called the same as your function. The token can be obtained from the Authentication tab in the project settings.
First, you need to create a new user with the signup function. Then, go to the Graphcool Playground:
graphcool playgroundand run this mutation to authenticate as that user:
mutation {
# replace __PHONE_NUMBER__ and __DEVICE_ID__
authenticatePhoneUser(phoneNumber: "__PHONE_NUMBER__", deviceId: "__DEVICE_ID__") {
token
}
}If the phoneNumber/deviceId combo are valid you should see that it returns a token. The returned token can be used to authenticate requests to your Graphcool API as that user.