# Keys for logging onto and using the athom-api

**URL:** <https://community.homey.app/t/keys-for-logging-onto-and-using-the-athom-api/34582>\
**Category:** Developers\
**Created:** [September 11, 2020, 11:32am UTC](https://community.homey.app/t/keys-for-logging-onto-and-using-the-athom-api/34582 "2020-09-11T11:32:43Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![Ragnar](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ragnar/32/18145_2.png) [@Ragnar](https://community.homey.app/u/Ragnar)\
**Post date:** [September 14, 2020, 9:46am UTC](https://community.homey.app/t/keys-for-logging-onto-and-using-the-athom-api/34582/8 "2020-09-14T09:46:51Z")

</div>

@Lammy, Ive had some progress obtaining the code. By using the \_csrf from the html, I was able to successfully post the form and receive the delegation code. Using python:

```
rescource = "resource.homey.###" 
pos_of_csrf = responds.text.find('input type="hidden" name="_csrf" value="') + 40
_csrf = rsp.text[pos_of_csrf:pos_of_csrf+36]
 
form_data = f"resource={rescource}&_csrf={_csrf}&allow=Allow"  
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
rsp_with_device = rq.post(url2, data=form_data, headers=headers)

code = rsp_with_device.url.split('=')[1]

```

I’ll continue experimenting with this towards [api.athom.com](http://api.athom.com). Thanks this far for the assist! Im sure Ill have some more questions as I continue [on your steps in the other post](https://community.homey.app/t/unsupported-homey-v2-rest-api/7268/47).

---

_[View the full topic](https://community.homey.app/t/keys-for-logging-onto-and-using-the-athom-api/34582)._
