Auth Token Service - Setup

One of the first things you need to do to start using the View and Data API is to get an Auth Token Server setup and working to authorize all your calls to the API. To help people over that intial speed bump, we have a "template" version of a simple AuthTokenServer.

Source code can be found here: SimpleAuthTokenServer on GitHub

The only file of real relevance is AuthTokenServer.js. It is a Node.js file that is started to run the service. The rest of the files in the project are files installed by Node.js package "Express" and a few config files that were used to deploy on Heroku.

You can run locally by doing the following:

  1. If Node.js is not installed, install it from: here
  2. Edit the file AuthTokenServer.js and add your developer keys to the appropriate endpoint (PRODUCTION at a minimum)
  3. Go to a Terminal window and change to the project directory.
  4. Run command: "node AuthTokenServer.js"
  5. Go to a Web browser and try the following URL: http://127.0.0.1:5000/
  6. That sould respond with a message "I'm Alive!"
  7. Then try URL: http://127.0.0.1:5000/auth
  8. That should send a response that looks something like: {"token_type":"Bearer","expires_in":1799,"access_token":"m2Y1gIgXYZZZZZZNzYgmQYoqK0"}
  9. From your app, you can now use this simple AuthTokenService to generate tokens which you use to make requests to the View and Data API.
  10. If you want, drop the file MyAuthToken.js into your app. Then you only have to create a new MyAuthToken object and call the .value() function anytime you need to return the auth token to an API.
  11. Later, you will want to deploy this AuthTokenServer to Heroku or some other hosting service (see Step 14 in the QuickStart Guide for more details on how to do this).

NOTE: if you need some help understanding how GitHub works, here are some good resources: