0

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.
timpham
  • 556
  • 2
  • 7
  • 25
  • Hey @timpham, do you have an existing Stormpath account on https://api.stormpath.com? If not, you won't be able to follow these tutorials, as registration has been disabled on Stormpath's site. You can read more about that here: https://stormpath.com/blog/stormpaths-new-path – mdegges Jun 14 '17 at 18:49
  • Yes i do. And here's the doc https://docs.stormpath.com/nodejs/product-guide/latest/auth_n.html#how-token-based-authentication-works which I follow. It still show sample code using the old JwtAuthenticator instead. – timpham Jun 16 '17 at 05:33

0 Answers0