Pomax / node-flickrapi

A node.js (and client-library) implementation of the Flickr API with oauth API key authentication and API method proxying

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

exporting ACCESS stuff in shell does not work

neojski opened this issue · comments

If I add user_id and friends to flickrOptions it works.

If I follow the instruction and export FLICKR_USER_ID it does not.

I searched for env in FlickrAPI but with no luck. Please let me know if this is supposed to work (if yes please point me to the code reading env variables so I can help debugging).

commented

if you're writing them to .env file, did you remember to load that in with something like habitat?

I'm just adding them as environment variables (that is, I ran export FLICKR_USER_ID=... in shell before running the script). From README I expected node-flickrapi to use sth like process.env to read them.

I haven't written them to .env file.

commented

which OS? (export won't work on Windows, for instance)

Linux. I'm pretty sure it also applies to osx. I don't really know if there's the concept of environment variables in windows.

commented

there is, it just doesn't use "export" in the slightest, hence the question. habitat should pick up on the global environment, after exporting, what does env say is your set of variables? Are the values in there?

Yes, the values are visible when I call env. I'm just confused because habitat thingy seems to be only used in compile.js file which isn't, as far as I see, used in FlickrAPI.

commented

it's just a general purposes environment loader, it has nothing to do with the Flickr API library: https://www.npmjs.com/package/habitat

Do the values show up if console.log process.env? (they will be case sensitive and not namespaced if you don't use habitat).

commented

@neojski would you still be willing to see what ends up in process.env so we can see if this is a problem with node-flickrapi? (if not, I'll close this issue in a few days during triage)

They do show up in process.env as expected.

commented

as what, though? habitat does a nice thing where it "gathers up" variables under a namespace, so FLICKR_USER_ID and FLICKR_ACCESS_TOKEN become an object { user_id: ..., access_token: ...} that you get from a habitat call env.get("flickr").

So if you're not using habitat, you'll have the wrong variable name and you need to do something like:

var FlickrOptions = {
  ...
  user_id: process.env.FLICKR_USER_ID,
  access_token: process.env.FLICKR_ACCESS_TOKEN,
  ...
}

It just isn't clear from the README that I was supposed to used habitat if I want this to work (and it's not explained how to use that habitat thingy). Inline configuration, however, works fine.

commented

Good point, I'll update the README.md for that.

commented

I've updated the README.mg, does the more elaborate text under https://github.com/Pomax/node-flickrapi#an-example-run address the issue you think, or is more work necessary to prevent other users from running into this as well?

@Pomax, you've messed up formatting in 6769cf2 (] is missing after habitat). I think it is better now providing that it works (I didn't have a chance to check it). If it does for you feel free to close this.

Thanks!

commented

easy enough to fix, thanks for that note.