@@ -14,9 +14,9 @@ This plugin was initially based off the `wp-api-jwt-auth` plugin by Enrique Chav
1414
1515## Install, Activate & Setup
1616
17- You can install and activate the plugin like any WordPress plugin. Download the .zip from Github and add to your plugins directory, then activate.
17+ You can install and activate the plugin like any WordPress plugin. Download the .zip from Github and add to your plugins directory, then activate.
1818
19- JWT uses a Secret defined on the server to validate the signing of tokens.
19+ JWT uses a Secret defined on the server to validate the signing of tokens.
2020
2121It's recommended that you use something like the WordPress Salt generator (https://api.wordpress.org/secret-key/1.1/salt/ ) to generate a Secret.
2222
@@ -25,7 +25,7 @@ You can define a Secret like so:
2525define( 'GRAPHQL_JWT_AUTH_SECRET_KEY', 'your-secret-token' );
2626```
2727
28- Or you can use the filter ` graphql_jwt_auth_secret_key ` to set a Secret like so:
28+ Or you can use the filter ` graphql_jwt_auth_secret_key ` to set a Secret like so:
2929
3030```
3131add_filter( 'graphql_jwt_auth_secret_key', function() {
@@ -51,15 +51,19 @@ For NGINX, this may work: https://serverfault.com/questions/511206/nginx-forward
5151
5252## How the plugin Works
5353
54- This plugin adds a new ` login ` mutation to the WPGraphQL Schema.
54+ ### Login User
5555
56- This can be used like so:
56+ This plugin adds a new ` login ` mutation to the WPGraphQL Schema.
5757
58- ```
58+ This can be used like so:
59+
60+ ** Input-Type:** ` LoginUserInput! `
61+
62+ ``` graphql
5963mutation LoginUser {
6064 login ( input : {
61- clientMutationId:"uniqueId"
62- username: "your_login"
65+ clientMutationId : " uniqueId" ,
66+ username : " your_login" ,
6367 password : " your password"
6468 } ) {
6569 authToken
@@ -71,13 +75,52 @@ mutation LoginUser {
7175}
7276```
7377
74- The ` authToken ` that is received in response to the login mutation can then be stored in local storage (or similar) and
75- used in subsequent requests as an HTTP Authorization header to Authenticate the user prior to execution of the
76- GraphQL request.
78+ The ` authToken ` that is received in response to the login mutation can then be stored in local storage (or similar) and
79+ used in subsequent requests as an HTTP Authorization header to Authenticate the user prior to execution of the
80+ GraphQL request.
7781
7882- ** Set authorization header in Apollo Client** : https://www.apollographql.com/docs/react/networking/authentication/#header
7983- ** Set authorization header in Relay Modern** : https://relay.dev/docs/en/network-layer.html
8084- ** Set authorization header in Axios** : https://github.com/axios/axios#axioscreateconfig
8185
86+
87+ ### Register User
88+
89+ ** Input-Type:** ` RegisterUserInput! `
90+
91+ ``` graphql
92+ mutation RegisterUser {
93+ registerUser (
94+ input : {
95+ clientMutationId : " uniqueId" ,
96+ username : " your_username" ,
97+ password : " your_password" ,
98+ email : " your_email"
99+ }) {
100+ user {
101+ jwtAuthToken
102+ jwtRefreshToken
103+ }
104+ }
105+ }
106+ ```
107+
108+ ### Refresh Auth Token
109+
110+ ** Input-Type:** ` RefreshJwtAuthTokenInput! `
111+
112+ ``` graphql
113+ mutation RefreshAuthToken {
114+ refreshJwtAuthToken (
115+ input : {
116+ clientMutationId : " uniqueId"
117+ jwtRefreshToken : " your_refresh_token" ,
118+ }) {
119+ authToken
120+ }
121+ }
122+ ```
123+
124+
82125## Example using GraphiQL
83126![ Example using GraphiQL] ( https://github.com/wp-graphql/wp-graphql-jwt-authentication/blob/master/img/jwt-auth-example.gif?raw=true )
0 commit comments