# Using curl in your terminal
curl https://api.spark.io/oauth/token -u spark:spark \
-d grant_type=password -d username=joe@example.com -d password=SuperSecret
hello,
I write very little English, excuse me.
I want to know to find the grant_type=password
I wrote a dll in C #, for Windows 7
thank you
Can you explain what do you need?
The password is your account password basically
I would like to find grant_type password
I do not know whether a Requet, get or post?
and protocol and host
@DavDesloges, you might want to read the docs closely: http://docs.spark.io/api/#introduction-list-devices
It says:
In the **POST** body, you need three parameters:
grant_type=password
username=YOUR_EMAIL@ADDRE.SS
password=YOUR_PASSWORD
I look at the Doc, but I do not know what to make grant_type = password.
That’s a parameter that you are passing along so it’s simply grant_type = password
.
Maybe someone else more familiar/experienced can help you in this area instead ![:wink: :wink:](https://community.particle.io/images/emoji/twitter/wink.png?v=5)
Perceverance, I found the solution for those interested, here it is in C #
must access a Post and Get
Access Bearer:
WebRequest req = WebRequest.Create(new Uri("https://www.spark.io/sign-in"));
req.Method = "POST";
req.ContentType = "application/json";
byte[] sentData = Encoding.UTF8.GetBytes("{\"username\":\"" + MyEmail + "\",\"password\":\"" + MyPassWord + "\"}";);
req.ContentLength = sentData.Length;
using (Stream sendStream = req.GetRequestStream())
{
sendStream.Write(sentData, 0, sentData.Length);
}
WebResponse res = req.GetResponse();
Stream ReceiveStream = res.GetResponseStream();
using (StreamReader sr = new StreamReader(ReceiveStream, Encoding.UTF8))
{
String ResultJson = sr.ReadToEnd();
}
ResultJson:
{
“username": “XXXXXX@XXXXXXX.XX”, // MyEmail
"is_elite": false,
“auth_token”:
{
“token”: “9sXXXXXXXXXXXXXXXXX”, // <= Bearer Token
"expires_at": “2015-08-10T17:21:14Z”
}
}
Access Tokens:
WebRequest http = HttpWebRequest.Create(new Uri("https://www.spark.io/access-token"));
http.Method = "GET";
http.ContentType = application/json;
var Header = new WebHeaderCollection();
Header.Add("Authorization", "Bearer " + "9sXXXXXXXXXXXXXXXXX"); // <= My Bearer Token
http.Headers = Header;
HttpWebResponse response = (HttpWebResponse)http.GetResponse();
Stream StreamResponse = response.GetResponseStream();
using (StreamReader reader = new StreamReader(StreamResponse, Encoding.UTF8))
{
String ResultJson2 = reader.ReadToEnd();
}
ResultJson2 :
{
“access_token”: “2axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”, // <= My Access_Token
"access_token_expires_at": “2015-06-T08:30:11+00:00”,
“spark_api_token”: “fbxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”
}
1 Like