rest-api-examples

Authorization code OAuth flow

This sample project demonstrates how a registered app can request authorization from Uphold users to perform actions on their behalf, by using the authorization code OAuth flow. For further background, please refer to the API documentation.

Summary

This flow is recommended for web applications that wish to retrieve information about a user’s Uphold account, or take actions on their behalf.

This process, sometimes called “3-legged OAuth”, requires three steps, each initiated by one of the three actors:

  1. The user navigates to Uphold’s website, following an authorization URL generated by the app, where they log in and authorize the app to access their Uphold account;
  2. Uphold redirects the user back to the app’s website, including a short-lived authorization code in the URL;
  3. The application’s server submits this code to Uphold’s API, obtaining a long-lived access token in response. (Since this final step occurs in server-to-server communication, the actual code is never exposed to the browser.)

This example sets up a local server that can be used to perform the OAuth web application flow cycle as described above.

Requirements

To run this example, you must have:

Setup

Run

Once the authorization is complete and an access token is obtained, the local server will use it to make a test request to the Uphold API. The output will be printed in the command line.