Unable to store api credentials in environment variables
Closed this issue · 1 comments
Module was working great as I tested with my Instagram credentials declared in the controller, but I can't get them to work as env variables. (The credentials are valid, and all my other env variables work.)
I scaffolded my app with the angular-fullstack Yeoman generator, and haven't changed its basic architecture. In /server/config/local.env.js I have:
(function()
{
'use strict';
module.exports = Env();
function Env()
{
var IEnvironmentVariables = {
// Instagram Credentials - placeholders here in internet-land, obviously
INSTAGRAM_ACCESS_TOKEN: 'my-access-token',
INSTAGRAM_CLIENT_ID: 'my-client-id',
INSTAGRAM_CLIENT_SECRET: 'my-client-secret'
};
return IEnvironmentVariables;
}
})();
In /server/config/environment/index.js:
instagram: {
accessToken: process.env.INSTAGRAM_ACCESS_TOKEN || process.env.OPENSHIFT_INSTAGRAM_ACCESS_TOKEN || 'instagram-access-token',
clientId: process.env.INSTAGRAM_CLIENT_ID || process.env.OPENSHIFT_INSTAGRAM_CLIENT_ID || 'instagram-client-id',
clientSecret: process.env.INSTAGRAM_CLIENT_SECRET || process.env.OPENSHIFT_INSTAGRAM_CLIENT_SECRET || 'instagram-client-secret'
}
In /server/api/feed/feed.controller.js:
var Instagram = require('instagram-node').instagram();
var config = require('../../config/environment').instagram;
Instagram.use({
access_token: config.accessToken,
client_id: config.clientId,
client_secret: config.clientSecret
});
The above Instagram.use({})
is returning 'instagram-access-token', 'instagram-client-id' and 'instagram-client-secret', the defaults from my config file when there aren't any environment variables found. I'm flummoxed. Help?
UPDATE: this has nothing to with node-instagram. I ported my SMTP setup to env variables and just realized I'm having the same problem with those. Sorry. Closing issue.