X - Internal (User-Side Integration)

Prerequisite: Connect Your X (Twitter) Account

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

Additionally, you can filter missions by type using the type query parameter with the value (X) to retrieve only Twitter-based missions

{
  "is_prerequisite_met" : false 
}

If the flag is false, users have to connect their Twitter account as the first step to process the missions. Use the X Connect API to connect the X account.


Connect X Mission

1. To initiate the connection, redirect the user to the Twitter authentication URL with the following parameters: Refer to the Twitter API documentation for more details.

API Endpoint:

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

Path Params:

NameTypeDescriptionRequired
tenantstringTenant slug (e.g., sample-loyalty)Yes

Query Params:

NameTypeDescriptionRequired
redirectstringURL to which the user should be redirected after completing Twitter authentication (e.g., https://example.com/ )Yes
user_referencestringUnique identifier for the user (e.g., user_<user-reference> or waller_address)No

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. Refer to the Twitter Connect API documentation for more details.

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 X (Twitter) Account

To disconnect the user's Twitter account, refer to the X Disconnect API documentation.

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"
    }