Install Oauth 2.0 Mock Server
This should help testing Oauth 2.0 implementation.
Step-by-step guide
- Install Node.js (https://nodejs.org/en/).
- Run CMD as Administrator.
- Go to Node.js installation folder (usually "Program Files\nodejs").
- Install NPM using the command "npm i mock-oauth-2-server" (if you are behind a proxy then follow this instruction first https://forum.freecodecamp.org/t/npm-behind-a-proxy-server/19386).
Create a server.js as follows:
const oauth2 = require('mock-oauth-2-server'); const mockData = { client: { id : 'oauth2_application_client_id', secret : 'oauth2_application_secret', redirectUris : ['http://localhost:5000/oauth2/redirect/callback'], grants: ['authorization_code'] }, user: { id : '123', uuid : 'dkalfyeoiqajaof', email: 'brad@email.com' }, jwtSecret: 'jwt_secret_key' }; let mock = new oauth2(mockData); mock.start();
- Start using command "node server".
Note: to generate access token, use:
const defaultGenerateAccessToken(client, user, scope) { return jwt.sign(user, 'im_a_secret', { algorithm: 'HS512', jwtid: uuid() }); }
Related articles
Filter by label
There are no items with the selected labels at this time.