Skip to content

Instantly share code, notes, and snippets.

@mpguerra
Last active August 29, 2015 14:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpguerra/dc9038419ae047fc7ff0 to your computer and use it in GitHub Desktop.
Save mpguerra/dc9038419ae047fc7ff0 to your computer and use it in GitHub Desktop.
Steps and links for 3scale Workshop: Crash Course - Practical API Management

Crash Course - Practical API Management

API and API Gateway

API Gateway

Alternative set up instructions

curl -u :`heroku auth:token` -H 'Accept: application/vnd.heroku+json; version=3' -X POST -d '
{
  "source_blob": {
    "url": "https://github.com/3scale/oneclick-api-gateway-heroku/tarball/master"
  },
  "app": {
    "stack": "cedar"
  },
  "overrides": {
    "env": {
      "BUILDPACK_URL": "http://github.com/leafo/heroku-buildpack-lua.git",
      "THREESCALE_DEPLOYMENT_ENV": "heroku-api",
      "THREESCALE_PROVIDER_KEY": "YOUR_PROVIDER_KEY",
      "THREESCALE_ADMIN_DOMAIN": "YOUR_ADMIN_DOMAIN"
    }
  }
}
' https://api.heroku.com/app-setups

You can then run, as for the API deployment to check when your application is deployed:

curl -n -X GET https://api.heroku.com/app-setups/YOUR_DEPLOY_ID -H "Accept: application/vnd.heroku+json; version=3"

Once that's succesfully deployed, you can try making some calls on your API through the gateway, e.g

curl -v -X GET https://YOUR-HEROKU-API-GATEWAY.herokuapp.com/api/meals.json?user_key=YOUR_USER_KEY

OAuth API Gateway

Pre-reqs: heroku toolbelt installed

###Set up

  1. Clone OAuth Gateway repo: git clone git@github.com:mpguerra/user-goals-oauth-api-gateway.git
  2. heroku apps:create --buildpack http://github.com/leafo/heroku-buildpack-lua.git <APPLICATION_NAME>
  3. heroku addons:add redistogo
  4. heroku addons:add threescale
  5. heroku addons:open threescale
  6. Get service_id and set environment variable heroku config:set THREESCALE_SERVICE_ID=<SERVICE_ID>
  7. Change auth mode to OAuth
  8. Create new developer account and set application's redirect url to: https://www.getpostman.com/oauth2/callback
  9. git push heroku master
  10. Get access token using POSTMAN
  11. Get user data for user identified by access token

Tools, commands and links

To get a list of sample users:

  1. heroku run console
  2. require './application'
  3. User.all

To log in as a user:

  1. take username from call above
  2. password is 'password'

To get a list of all tokens assigned to an application:

curl -X GET "http://su1.3scale.net/services/<SERVICE_ID>/applications/<CLIENT_ID>/oauth_access_tokens.xml?provider_key=<PROVIDER_KEY>"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment