Updated nodejs Doc
This commit is contained in:
Родитель
2082bd16f9
Коммит
de1b85c010
|
@ -4,11 +4,9 @@ lodash: true
|
|||
|
||||
##NodeJS
|
||||
|
||||
If you're creating a new NodeJS api that you'll use with your <%= configuration.frontend || 'Frontend' %> code, you can [click here to download](https://github.com/auth0/auth0-nodejsapi-sample/archive/master.zip) a seed project that is already configured to use Auth0.
|
||||
<a href="https://docs.auth0.com/node-auth0/master/create-package?path=examples/nodejs-api&type=server@@account.clientParam@@" class="btn btn-lg btn-success btn-package"> Click here to download a Seed project<% if (account.userName) { %> with your Auth0 account information<% } %></a>
|
||||
|
||||
Then, you just need to specify your Auth0 account configuration in the `.env` file: [https://github.com/auth0/auth0-nodejsapi-sample#running-the-example](https://github.com/auth0/auth0-nodejsapi-sample#running-the-example)
|
||||
|
||||
Otherwise, Please follow the steps below to configure your existing NodeJS app to use it with Auth0.
|
||||
**Otherwise, Please follow the steps below to configure your existing NodeJS app to use it with Auth0.**
|
||||
|
||||
### 1. Add express-jwt dependency
|
||||
|
||||
|
@ -25,7 +23,6 @@ npm install express-jwt --save
|
|||
You need to set the ClientID and ClientSecret in `express-jwt`'s configuration so that it can validate and sign [JWT](https://docs.auth0.com/jwt)s for you.
|
||||
|
||||
````js
|
||||
var http = require('http');
|
||||
var express = require('express');
|
||||
var app = express();
|
||||
var jwt = require('express-jwt');
|
||||
|
@ -41,15 +38,7 @@ You need to set the ClientID and ClientSecret in `express-jwt`'s configuration s
|
|||
Now, you need to specify one or more routes or paths that you want to protect, so that only users with the correct JWT will be able to do the request.
|
||||
|
||||
````js
|
||||
app.configure(function () {
|
||||
|
||||
// ...
|
||||
|
||||
app.use('/api/path-you-want-to-protect', jwtCheck);
|
||||
|
||||
// ...
|
||||
|
||||
});
|
||||
app.use('/api/path-you-want-to-protect', jwtCheck);
|
||||
```
|
||||
|
||||
### 4. You've nailed it.
|
||||
|
|
Загрузка…
Ссылка в новой задаче