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 = "https://api.intel.com/catalog/v1/{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
http://software.intel.com/cloudservicesplatform/documentation/using-comm...

(2) Intel® Cloud Services Platform beta Catalog Services REST API Reference
http://software.intel.com/cloudservicesplatform/documentation/intel-clou...

(3) Intel® Cloud Services Platform beta Identity Services .NET Developer's Guide
http://software.intel.com/cloudservicesplatform/documentation/intel-clou...

Thanks<

3 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

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 norman.chou@intel.com. I will send you the source code, the forum won't let me send the code over.

Thanks,

Norm

Connectez-vous pour laisser un commentaire.