Does anyone know how to get oauth2 token using Unity C# WWW/WWWForm?
Hi, I am running an app in Unity which requires Domo Authentication to get the token. The problem is I keep getting "401 Unauthorized" error and "{"error":"invalid_client","error_description":"Bad client credentials"}"(from WWW.text).
Here's my code:
IEnumerator getTokenNew()
{
string jSon = client_id + ":" + client_secret;
Dictionary<string,string> postheader = new Dictionary<string,string>();
postheader.Add ("Content-Length",jSon.Length.ToString());
postheader.Add ("Content-Type","application/json");
postheader.Add ("Allow","PUT");
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
WWW www = new WWW ("https://api.domo.com/oauth/token?grant_type=client_credentials&scope=data%20user",encoder.GetBytes(jSon),postheader);
yield return www;
Debug.Log (www.text);
Debug.Log (www.error);
}
The WWW constructor has three arguments, which are url, byte of data, and a dictionary for creating headers. Does anyone know how to send a request with this? I have theoriginal cUrl code, but can not really translate into C sharp WWW. Thanks. Here is the API Documentation: WWW_UNITY_API
cUrl:
$ curl -v -u {CLIENT_ID}:{CLIENT_SECRET} "https://api.domo.com/oauth/token?grant_type=client_credentials&scope={SCOPE}"
Sample cUrl:
$ curl -v -u 441e307a-b2a1-4a99-8561-174e5b153fsa:f103fc453d08bdh049edc9a1913e3f5266447a06d1d2751258c89771fbcc8087 "https://api.domo.com/oauth/token?grant_type=client_credentials&scope=data%20user"
Comments
-
Can someone provide some assistance on this topic?
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 738 Beast Mode
- 56 App Studio
- 40 Variables
- 684 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 35 Predict
- 14 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 123 Manage
- 120 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive