A Sinatra app for supporting Authorization Code Flow on Coinbase
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.env.example
.gitignore
Gemfile
Gemfile.lock
Procfile
README.md
app.json
coinbase_token_swap.rb
config.ru
puma.rb

README.md

Coinbase Token Swap

Based heavily off Spotify Token Swap. This is a Sinatra app for supporting the auth flow on Coinbase. The main primary reason for using a service like this is so you don't have to store your secret key in your iOS/macOS application.

Deploy To Heroku

Deploy

Configuration

The app expects these ENV variables:

  • CLIENT_ID
  • CLIENT_SECRET
  • CLIENT_REDIRECT_URL

For local development you will need to create a .env file that uses the format of the .env.example file included in the repository.

API

POST /api/token

Request

curl -X "POST" "https://<you-url>/api/token" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "code": "<code>"
}'

Response

{
  "access_token" : "...",
  "token_type" : "bearer",
  "expires_in" : 7200,
  "refresh_token" : "...",
  "scope" : "wallet:user:read wallet:accounts:read"
}

POST /api/refresh_token

Request

curl -X "POST" "https://<you-url>/api/refresh_token" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "refresh_token": "<refresh-token>"
}'

Response

{
  "access_token" : "...",
  "token_type" : "bearer",
  "expires_in" : 7200,
  "refresh_token" : "...",
  "scope" : "wallet:user:read wallet:accounts:read"
}