Tutorial

Select the API you want to start with:

Use OAuth API with Foursquare

1. Sign up for an Apigee Free account or Sign in.

2. Create an application on Apigee.com

  1. Click on: https://apigee.com/oauth_api
  2. Click on the Add App button to launch the setup form
  3. Name your OAuth API App
  4. Confirm that the Base URL is what you want for your app.(You’ll make all API calls through this URL.)
  5. Click Create Base URL

3. Add Foursquare to your App

  1. At Apigee OAuth API app setup form...
  2. Select Foursquare from the API Providers dropdown
  3. Copy the callback URL, (you’ll need this for Foursquare)
  4. View details of creating applications in Foursquare (opens in new window)
  5. Visit https://foursquare.com/oauth to launch a new window/tab with Foursquare
  6. Sign in to Foursquare and create a new application
  7. Fill out the form. Paste the callback URL for your Apigee OAuth API app
  8. Accept terms and create your Foursquare App
  9. Copy your Foursquare App Client ID and paste it into the Apigee OAuth API setup form.
  10. Copy your Foursquare App Client Secret and paste it into the Apigee OAuth API setup form.
  11. Click Finish to complete your OAuth API App.
  12. When you return to the OAuth API apps list page, make a note of your Base URL, you'll need this later.

4. Add a User for your App

Every user of your app gets a unique token, called a SmartKey. Every time you create a user, you get a SmartKey in return. Apigee will associate Foursquare credentials with that SmartKey.

So now you'll create your first user. The fastest way is to use the Apigee Console to make an API request to the OAuth API. This will help teach you how to use the OAuth API so that when you're ready, you can build support for adding user into your app.

  1. In the Console
  2. Click on the Service dropdown and select the base URL: https://{appname}-api.apigee.com/v1
  3. Choose the expand method list icon and select the Create User method from the Managing Users group
  4. On the Template tab, supply your app name as the value
  5. One the Body tab and supply the values for userName, fullName, and password
  6. Send your request
  7. Expect a response that looks like the following: applicationUserId: 322, fullName: "Demo User1", smartKey: "4ec64ef1-7361-456e-95cf-562ed39fddd3", userName: "demouser1", appName: "apigeedemoapp"
  8. Make a note of the SmartKey value you get from the Console. You’ll use that next.

Authenticate the user with Foursquare

  1. Open a new browser window
  2. Assemble the AuthURL for Foursquare. Copy and paste this into your location bar: https://REPLACE_WITH_YOUR_APPNAME-api.apigee.com/v1/providers/foursquare/authorize?smartkey=PASTE_SMARTKEY
  3. Paste your Auth URL to initiate the OAuth Dance with Foursquare.
  4. Change the appname to your appname in the URI.
  5. Change the smartkey for a user that has been authorized with Foursquare on the end of the URI.
  6. Hit return to submit the URL. (You'll be redirected to Foursquare)
  7. After signing in with Foursquare and Authorizing the app to access Foursquare, you’re done.
  8. That’s it! All of the credential updating for your user is done behind the scenes in the Apigee Gateway.

5. Make authenticated requests with a Smartkey

  1. Open a new browser window
  2. Copy and paste this into your location bar: https://REPLACE_WITH_YOUR_APPNAME-api.apigee.com/v1/foursquare/v2/settings/all?smartkey=PASTE_SMARTKEY
  3. Change the appname to your appname in the URI.
  4. Change the smartkey for a user that has been authorized with Foursquare on the end of the URI.
  5. Hit return to submit the URL.
  6. You should see the JSON of a Foursquare home_timeline response, without any of the mess with OAUTH.