How To Generate an Auth Token for the Data API?

This article explains how to generate an Auth Token for the Data API using the provided script.

Instructions

  1. Input required
    • Workspace ID (earlier app id) 
    • API key

    To find the Workspace ID and API key, go to Settings > APIs in the MoEngage dashboard.Auth token.png

  2. Generate the Auth Token:

    Use the following script to generate the Auth Token for the specified app:

Python
import base64
import subprocess

app_id = str(input("Enter the APP ID or Worskspace ID: ")).strip()
app_key = str(input("Enter the secret key: ")).strip()
secret_string = app_id + ":" + app_key
secret_string_bytes = secret_string.encode("ascii")
base64_bytes = base64.b64encode(secret_string_bytes)
base64_string = base64_bytes.decode("ascii")

subprocess.run("pbcopy", text=True, input=base64_string)
print("Token copied to your clipboard")
info

Information

Once executed, the Auth Token will be generated and automatically copied to the clipboard. 

Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?