graphql-with-auth
This is an example of a protected graphql API, to which the user will need to authenticate using a JWT. This example API needs to be running for these example projects to work:
Last updated 3 years ago by nmaro .
ISC · Original npm · Tarball · package.json
$ cnpm install graphql-with-auth 
SYNC missed versions from official npm registry.

A protected graphql API

This is an example of a protected graphql API, to which the user will need to authenticate using a JWT. This example API needs to be running for these example projects to work:

Start it

Copy settings.dist.js to settings.js and adapt.

Run

npm start

The GraphQL endpoint is /graphql. Visit /graphiql to play with the data.

Notice how you can query posts and comments, but not insert any without having logged in.

Logging in with a client

ooth-client of course is supposed to do all of this for you - see its usage in ooth-create-react-app or ooth-next.

Logging in (low level)

To be able to login you need to start the companion example ooth server.

Once started register as a guest:

curl -XPOST {oothserver}/guest/register

will get you a JWT token

then

curl -XPOST {apiserver}/login --header "Authorization: JWT {enterjwttokenhere}" -c -

this will print the session cookie created by the server

  • if you had done this request in a browser you could now start performing write queries to the graphql api.

Current Tags

  • 0.0.0                                ...           latest (3 years ago)

1 Versions

  • 0.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 6
Dependencies (13)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |