# Cloud API for access\_token

**URL:** <https://community.particle.io/t/cloud-api-for-access-token/1020>\
**Category:** Cloud\
**Created:** [December 27, 2013, 3:49am UTC](https://community.particle.io/t/cloud-api-for-access-token/1020 "2013-12-27T03:49:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carsten4207](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/carsten4207/32/130_2.png) [@Carsten4207](https://community.particle.io/u/Carsten4207)\
**Post date:** [December 27, 2013, 3:49am UTC](https://community.particle.io/t/cloud-api-for-access-token/1020/1 "2013-12-27T03:49:14Z")

</div>

Hi again,

I was wondering if there is an endpoint/api where I can pass in my [Spark.io](http://Spark.io) email address and password and have it return the access\_token to make the API calls?

I know the documentation mentions it using OAuth 2 but I didn’t see any endpoints/api.

Thanks again!

Carsten Dressler

---

<div class="post-metadata">

**Author:** ![Carsten4207](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/carsten4207/32/130_2.png) [@Carsten4207](https://community.particle.io/u/Carsten4207)\
**Post date:** [December 28, 2013, 11:25pm UTC](https://community.particle.io/t/cloud-api-for-access-token/1020/2 "2013-12-28T23:25:09Z")

</div>

Since I had no reply I took it upon myself to dig a little deeper. Here is what I found:

**Authentication**  
POST to [https://www.spark.io/sign-in](https://www.spark.io/sign-in)  
Headers: Content-Type: application/json  
Body: {“username”:“youremailaddress”,“password”:“spark\_password”}

This returns the following:

{  
“username”: "xxxxx@xxx.com",  
“auth\_token”: {  
“token”: “78n4xGh2aC\_V8awk4jsA”,  
“expires\_at”: “2014-05-19T13:31:05Z”  
}  
}

**To get access\_token**  
GET [https://www.spark.io/access-token](https://www.spark.io/access-token)  
Headers: Content-Type: application/json  
Authorization: Bearer 78n4xGh2aC\_V8awk4jsA

NOTE: in the Authorization header, you need to add "Bearer " + token.

This returns the following:

{  
“access\_token”: “asdfjaskfdjfksajfalfjsfkfjdkfadf”,  
“access\_token\_expires\_at”: “2014-03-23T15:51:07+00:00”  
}

Use this “access\_token” to make requests to the API’s provided in the documents!

**List devices the currently authenticated user has access to.**

[https://api.spark.io/v1/devices?access\_token=asdfjaskfdjfksajfalfjsfkfjdkfadf](https://api.spark.io/v1/devices?access_token=asdfjaskfdjfksajfalfjsfkfjdkfadf)

NOTE: I replaced the actual tokens/keys with fake keys. So the links do not work unless you run it on your own account and get your tokens/keys.

Hope this helps someone else!

Regards,  
Carsten Dressler

---

<div class="post-metadata">

**Author:** ![BDub](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bdub/32/5137_2.png) [@BDub](https://community.particle.io/u/BDub)\
**Post date:** [December 28, 2013, 11:53pm UTC](https://community.particle.io/t/cloud-api-for-access-token/1020/3 "2013-12-28T23:53:28Z")

</div>

I just tried this and it works 🙂 However is there any reason you wouldn’t just log into Spark Build [http://spark.io/build](http://spark.io/build) and look at the Settings page? I’m guessing you are working on completely automating some kind of mesh network or something?  
 ![](https://sea2.discourse-cdn.com/flex026/uploads/particle/131/9f3901f08cad7e6c.png)

---

<div class="post-metadata">

**Author:** ![Carsten4207](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/carsten4207/32/130_2.png) [@Carsten4207](https://community.particle.io/u/Carsten4207)\
**Post date:** [December 29, 2013, 12:00am UTC](https://community.particle.io/t/cloud-api-for-access-token/1020/4 "2013-12-29T00:00:55Z")

</div>

Yeah I do realize you can do it manually… but I wanted something more automatic 😃

---

<div class="post-metadata">

**Author:** ![spydrop](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@spydrop](https://community.particle.io/u/spydrop)\
**Post date:** [March 9, 2014, 4:29am UTC](https://community.particle.io/t/cloud-api-for-access-token/1020/5 "2014-03-09T04:29:00Z")

</div>

I know this is getting dated but, is there an App that can display all: MAC Address; ID; Token & Devices to that account all on the same parsed page ?

---

<div class="post-metadata">

**Author:** ![zach](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/zach/32/20714_2.png) [@zach](https://community.particle.io/u/zach)\
**Post date:** [March 9, 2014, 3:21pm UTC](https://community.particle.io/t/cloud-api-for-access-token/1020/6 "2014-03-09T15:21:57Z")

</div>

You can, in fact, do this through the API:

[http://docs.spark.io/#/api/authentication-generate-a-new-access-token](http://docs.spark.io/#/api/authentication-generate-a-new-access-token)

**EDIT:** Just realized that this post is a few months old, and this feature didn’t exist when it was posted 🙂 Well now it does!

---

<div class="post-metadata">

**Author:** ![elbeardo](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/elbeardo/32/98_2.png) [@elbeardo](https://community.particle.io/u/elbeardo)\
**Post date:** [August 15, 2014, 10:44am UTC](https://community.particle.io/t/cloud-api-for-access-token/1020/7 "2014-08-15T10:44:26Z")

</div>

Just following up on this. I’m trying to list my tokens via the Cloud API.

I’m getting a Unauthorised response back when I send my credentials in using Basic Auth in the header. i.e:

GET [https://api.spark.io/v1/access\_tokens](https://api.spark.io/v1/access_tokens) Headers [Accept=application/json,Accept-Encoding=gzip, deflate,Authorization=BASIC BASE64\_ENCODED\_CREDENTIALS\_HERE]

I’ve check my credentials, perhaps I’m missing something else?
