X User Integration

1. Claiming X-Based Missions

In the missions list or Get mission API,a flag is returned to indicate whether the user has connected X account. Use this flag to determine if the user can proceed with the mission flow.

{
  "is_prerequisite_met" : false 
}

If the flag is false, users have to connect twitter account as the first step to process the missions. Use https://loyaltydocs.getmojito.com/reference/twitter-connect#/ to connect X account.

1.1. Connect X Mission

🔁 Authorisation Flow

1. To initiate the connection, redirect the user to the Twitter authentication URL with the following parameters:: https://loyaltydocs.getmojito.com/reference/twitter#/ for reference

API Endpoint:

GET https://loyaltyapi.getmojito.com/{tenant}/social/twitter/auth

Path Params:

  • tenant (string, required): Tenant slug (e.g., sample-loyalty)

Query Params:

  • redirect (string, required): URL to which the user should be redirected after completing Twitter authentication (e.g., https://example.com/)
  • user_reference (string, optional): Unique identifier for the user (e.g., user_<user-reference>)

Response

{
  "data": "https://x.com/i/oauth2/authorize?client_id=UnAzWEk5ODMtdTJpZG5DQ2txZTI6MTpjaQ&response_type=code&redirect_uri=https://loyaltyapi.getmojito.com/social/twitter/auth/callback&scope=users.read tweet.read offline.access like.read follows.read follows.write&state=eyJhbGciOiJFUzI1NiIsImtpZCI6IjEifQ.eyJjb2RlX3YiOiJJQ2JRYV9NNjc3cHJrMnZyRnVRWSIsImV4cCI6MTc0NDc4NTgyNSwiaG9zdCI6ImxvY2FsaG9zdDo4MDgwIiwicmVkaXIiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTEwOS0tbW9qaXRvbG95YWx0eS5uZXRsaWZ5LmFwcC9kYXNoYm9hcmQvOTMzMmEzNGEtNzQ5Zi00NDZiLWIwNmEtZDcwZDgzMWE5ODEyLzkzMzJhMzRhLTc0OWYtNDQ2Yi1iMDZhLWQ3MGQ4MzFhOTgxMiIsInVzZXJfaWQiOiJiNjI1YzA5MC1hZjQ5LTQ0YTQtYjc0MC1mNmNiNDg1ZjAyYzQifQ._1pM6Rx666yv8VjK19OGUWpuxzrsEP4cb88TgAjfRB23TYbwR4_-8SQZlgLXIGvvUMMXo7SLvbuFOVzKcabmOg&code_challenge=ICbQa_M677prk2vrFuQY&code_challenge_method=plain"
}
  • Use Twitter OAuth to allow users to connect their Twitter account to your application.

2. After successful Twitter authentication, Twitter redirects the user to an internal callback handler.

API Endpoint:

GET https://loyaltyapi.getmojito.com/social/twitter/auth/callback	
  • This internal endpoint handles the callback by
    • Validating the received code and state.
    • Completing the connection flow by calling the token exchange internally.
    • Redirecting the user to the original redirect URL provided in the initial request.

3. Once the user is redirected back, call the backend API to complete the Twitter account connection. https://loyaltydocs.getmojito.com/reference/twitter-connect#/ for reference

API Endpoint:

POST https://loyaltyapi.getmojito.com/{tenant}/social/twitter/user/connect	

Request Body:

{
  "code": "<AUTHORIZATION_CODE>",
  "state": "<UNIQUE_STATE_STRING>",
  "user_reference": "user_<user-reference>"
}
  • Response:
{
  "message": "Twitter Account connected successfully"
}

🧾 Claim the Mission

🔌 Disconnect Twitter Account

To disconnect the user's Twitter account: https://loyaltydocs.getmojito.com/reference/twitter-disconnect#/ for reference

API Endpoint:

POST https://loyaltyapi.getmojito.com/{tenant}/social/twitter/user/disconnect	
  • Request Body:
{
  "user_reference": "user_<user-reference>"
}
  • Response:
  • {
      "message": "Twitter Account disconnected successfully"
    }