Skip to content

🚀 Quick Start Guide

Prerequisites

Before you begin, make sure you have:

  • Partner Account: Registered with Earth Miles
  • Client Credentials: Your client_id and client_secret
  • Redirect URI: Registered callback URL for your application
  • Development Environment: Server-side application to securely handle tokens
  • Know the required OAuth Scopes:
    • miles:read – Read user miles data
    • miles:write – Award points and process transactions

How to Integrate

1. Set Up OAuth Flow

Redirect users to our authorization endpoint with these parameters:

GET https://webapp.earthmiles.app/oauth/authorize?
  client_id=YOUR_CLIENT_ID&
  redirect_uri=YOUR_CALLBACK_URL&
  scope=miles:read%20miles:write&
  state=RANDOM_STATE&
  response_type=code&
  code_challenge=CODE_CHALLENGE&
  code_challenge_method=S256

2. Handle the Callback

Exchange the authorization code for tokens:

curl -X POST https://backend.earthmiles.app/api/oauth/token \
  -H "Content-Type: application/json" \
  -d '{
    "grant_type": "authorization_code",
    "code": "AUTHORIZATION_CODE",
    "client_id": "YOUR_CLIENT_ID",
    "client_secret": "YOUR_CLIENT_SECRET",
    "code_verifier": "CODE_VERIFIER"
  }'

3. Award Points

Use the access token to award miles:

curl -X POST https://backend.earthmiles.app/api/partner-api/award-points \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "user123",
    "categoryId": "your_category_id",
    "pointsToAward": 100
  }'