How can I get an auth token programatically?

How can I get an auth token programatically?

Hello there,

I was creating a dataset in C# using the following code:

string serviceUrl = "{0}";
string dataSetName = "myDataBase";
string apiKeyClientId = "AUTH_TOKEN";
string clientName = "Bearer"; 

WebRequest request = WebRequest.Create(string.Format(serviceUrl, dataSetName));
request.Headers.Add("Authorization", string.Format("{0} {1}", clientName, apiKeyClientId));
request.Timeout = 10000;
request.ContentType = "application/json";
request.Method = "POST";

string responseStr = string.Empty;
using (WebResponse resp = request.GetResponse())
HttpStatusCode status = ((HttpWebResponse)resp).StatusCode;
if ((status == HttpStatusCode.OK) && (resp != null))
StreamReader sr = new StreamReader(resp.GetResponseStream());
responseStr = sr.ReadToEnd().Trim();

But I'm stucked creating the auth token. The (3) example shows how to get the auth token in the querystring once the END USER has signed up:

// STEP #2: Receive /auth response
OAuth2Authorization auth = new OAuth2Authorization
Code = Request.QueryString["code"],
Error = Request.QueryString["error"],
State = Request.QueryString["state"]

In my case I need to create a dataset, then a collection and an item. How can I get an auth token programatically? I'm not an end user, so the scenario described in the MVC sample site does not fit to me because I'm building a library, not a web site.

I used the following links as references:

(1) Using Commerce Services REST APIs – C#.NET tutorial

(2) Intel® Cloud Services Platform beta Catalog Services REST API Reference

(3) Intel® Cloud Services Platform beta Identity Services .NET Developer's Guide


3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Let me investigate, we will contact you soon

Hi, my name is Norm Chou and I'm a technical marketing engineer for Intel Cloud Services.

I help developers utilize the Cloud Services. I have a sample C# code that will get you the 3 leg authentication and use the catalog services.

Please email me at I will send you the source code, the forum won't let me send the code over.



Leave a Comment

Please sign in to add a comment. Not a member? Join today