timpham
timpham

Reputation: 565

Stormpath secure rest api

I followed the example here https://stormpath.com/blog/the-ultimate-guide-to-mobile-api-security

and here to acquire an access token

https://support.stormpath.com/hc/en-us/articles/225610107-How-to-Use-Stormpath-for-Token-Management

"use strict";

import { ApiKey } from 'stormpath'; 
import { Client } from 'stormpath';

let apiKey = new ApiKey(process.env.STORMPATH_API_KEY_ID,
     process.env.STORMPATH_API_KEY_SECRET);

let spClient = new Client({apiKey: apiKey });

spClient.getApplication(process.env.STORMPATH_APPLICATION_HREF,
   function(err, app) {

    var authenticator = new OAuthAuthenticator(app);

    authenticator.authenticate({
        body: {
            grant_type: 'password',
            username: username,
            password : password
        }
    }, function (err, result) { 
        if (!err) console.log(err);
        res.json(result.accessTokenResponse);
    });
});

I was able to acquire a access_token. I use this token to hit my api with Header Authorization Bearer {access_token}

However, when i put in the middleware stormpath.apiAuthenticationRequired, i keep getting this warning and my api is returned with 401

(node:57157) DeprecationWarning: JwtAuthenticator is deprecated, please use StormpathAccessTokenAuthenticator instead.

Upvotes: 0

Views: 109

Answers (0)

Related Questions