# Login via API not working

**URL:** https://forum.remote.it/t/login-via-api-not-working/188
**Category:** API
**Created:** [May 30, 2020, 11:20pm UTC](https://forum.remote.it/t/login-via-api-not-working/188 "2020-05-30T23:20:34Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![MarkoD](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@MarkoD](https://forum.remote.it/u/MarkoD)
#### Post date: [May 30, 2020, 11:20pm UTC](https://forum.remote.it/t/login-via-api-not-working/188/1 "2020-05-30T23:20:34Z")

</div>

Hi,

I have a script written in PHP which logs in using the API and connects to a service. The script worked fine a couple of months ago, however when I try it now, it simply does not work.

The endpoint `https://api.remot3.it/apv/v27/user/login` returns a 404 (Not Found) error. I’ve also tried `https://api.remote.it/apv/v27/user/login` but it always returns a 403 with a JSON message: “Forbidden”. I’ve double-checked my username, password and API key.

Thanks for any insight on the topic!

Marko

---

<div class="post-metadata">

### Author: ![gary](https://avatars.discourse-cdn.com/v4/letter/g/839c29/32.png) [@gary](https://forum.remote.it/u/gary)
#### Post date: [June 2, 2020, 5:09pm UTC](https://forum.remote.it/t/login-via-api-not-working/188/2 "2020-06-02T17:09:41Z")

</div>

Are you still having this problem? I can’t reproduce it.

---

<div class="post-metadata">

### Author: ![MarkoD](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@MarkoD](https://forum.remote.it/u/MarkoD)
#### Post date: [June 2, 2020, 7:25pm UTC](https://forum.remote.it/t/login-via-api-not-working/188/3 "2020-06-02T19:25:39Z")

</div>

It’s fixed now, the original URL works again and doesn’t throw a 404.

---

<div class="post-metadata">

### Author: ![Arbi](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@Arbi](https://forum.remote.it/u/Arbi)
#### Post date: [February 26, 2023, 2:47pm UTC](https://forum.remote.it/t/login-via-api-not-working/188/4 "2023-02-26T14:47:28Z")

</div>

Hi,  
I have the same issue with python, I’ve tried with the endpoint _`https://api.remot3.it/apv/v27/user/login`_ and _`https://api.remote.it/apv/v27/user/login`_ but I get 400 error, I think the request that I’m making is malformed.  
this is my script:

> key\_id = R3\_ACCESS\_KEY\_ID  
> key\_secret\_id = R3\_SECRET\_ACCESS\_KEY  
> api\_key = DEVKEY
> 
> host = ‘api.remot3.it’  
> url\_path = “/apv/v27/user/login”  
> content\_type\_header = ‘application/json’  
> headers = {  
> ‘host’: host,  
> ‘content-type’: content\_type\_header,  
> ‘DeveloperKey’: api\_key  
> }  
> response = requests.post(‘https://’ + host + url\_path,  
> auth=HTTPSignatureAuth(algorithm=“hmac-sha256”,  
> key=b64decode(key\_secret\_id),  
> key\_id=key\_id,  
> headers=[  
> ‘(request-target)’, ‘host’,  
> ‘date’, ‘content-type’,  
> ]),  
> headers=headers)
> 
> if response.status\_code == 200:  
> print(response.text)  
> else:  
> print(response.status\_code)  
> print(response.text)

this is the output:

> 400  
> {“status”:“false”,“reason”:“post data missing”,“code”:“GENERAL\_ERROR”}

Thanks for any help!

---

<div class="post-metadata">

### Author: ![Arbi](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@Arbi](https://forum.remote.it/u/Arbi)
#### Post date: [February 27, 2023, 8:00pm UTC](https://forum.remote.it/t/login-via-api-not-working/188/5 "2023-02-27T20:00:47Z")

</div>

hello,  
I was able to solve this issue, this is my new code:

> import requests  
> from requests\_http\_signature import HTTPSignatureAuth, algorithms  
> from base64 import b64decode
> 
> ##GLOBALS##  
> DEVKEY =“_**"  
> R3\_ACCESS\_KEY\_ID="**_”  
> R3\_SECRET\_ACCESS\_KEY=“\*\*\*\*\*\*\*\*\*\*\*\*\*”  
> HOST = ‘api.remote.it’  
> CONTENT\_TYPE\_HEADER = ‘application/json’  
> CACHE\_CONTROL = “no-cache”
> 
> URL\_PATH\_CONNECT = “/apv/v27/user/login”
> 
> class RemoteIt:  
> def **init** (self,  
> devkey=DEVKEY,  
> host=HOST,  
> key\_id=R3\_ACCESS\_KEY\_ID,  
> key=R3\_SECRET\_ACCESS\_KEY,  
> content\_type=CONTENT\_TYPE\_HEADER,  
> cache=CACHE\_CONTROL):  
> self.devkey = devkey  
> self.host = host  
> self.key\_id = key\_id  
> self.key = key  
> self.content\_type = content\_type  
> self.cache\_control = cache
> 
> ```
> def connect(self):
> data = {
> "username": "my email"
> }
> CONTENT_LENGTH_HEADER = str(len(data))
> headers = {
> 'host': self.host,
> 'content-type': self.content_type,
> 'cache-control': self.cache_control,
> 'DeveloperKey': self.devkey,
> 'content-length':CONTENT_LENGTH_HEADER
>         
> }
>     
> response = requests.post(f'https://{self.host}{URL_PATH_CONNECT}',
> json=data,
> auth=HTTPSignatureAuth(signature_algorithm=algorithms.HMAC_SHA256,
> key=b64decode(self.key),
> key_id=self.key_id),
> headers=headers)
> print(f'Status code: {response.status_code}')
> print(f'Response content: {response.text}')
> if response.status_code == 200:
> if response.content != b'':
> print('Response content:', response.content)
> else:
> print('Server returned an empty response')
> else:
> print('Failed to get response from server. Status code:', response.status_code)
> print(response.status_code)
> print(response.text)
> 
> ```

and this what I get in the output:

> Status code: 200  
> Response content:  
> Server returned an empty response

it seems like the server is not returning any data in the response body, hence why `response.content` returns an empty `bytes` object `b''`. This could be due to several reasons, such as an error in the server-side code, an issue with the request format, or perhaps a configuration issue on the server side. I’m not sure of the required fields for the `login` endpoint and I can’t find any clue.  
Is there any other documentation for the REST API, there is nothing on this page: [https://docs.remote.it/api-reference/authentication/overview](https://docs.remote.it/api-reference/authentication/overview) .  
I appreciate any help!

---

<div class="post-metadata">

### Author: ![bstrech](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.remote.it/bstrech/32/266_2.png) [@bstrech](https://forum.remote.it/u/bstrech)
#### Post date: [February 27, 2023, 11:29pm UTC](https://forum.remote.it/t/login-via-api-not-working/188/6 "2023-02-27T23:29:47Z")

</div>

With the Remote.It API’s you no longer need to request /login.

You can just make your request directly provided you do the request signing correctly. We are also working on deprecating the REST API so if you are just getting started, you should be using the graphQL API which is documented and has an Insomnia collection which can help you get going.  
[https://link.remote.it/docs/insomnia](https://link.remote.it/docs/insomnia)

Please note, you cannot generate code out of Insomnia since the signing will no longer be valid. Request signing encodes the key, content-type, request time (needs to be within a couple of seconds of the request time in UTC) and content-length.  
For more on API authentication, please refer to [API Authentication](https://link.remote.it/docs/api/authentication)

---

<div class="post-metadata">

### Author: ![Arbi](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@Arbi](https://forum.remote.it/u/Arbi)
#### Post date: [February 28, 2023, 11:51am UTC](https://forum.remote.it/t/login-via-api-not-working/188/7 "2023-02-28T11:51:52Z")

</div>

Hello,  
Yes, the request works correctly with GraphQL API, also I was using requests\_http\_signature==v0.7.1 I changed it to v0.1.0. Now I can get all the information that I need.  
Thanks!

---

<div class="post-metadata">

### Author: ![bstrech](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.remote.it/bstrech/32/266_2.png) [@bstrech](https://forum.remote.it/u/bstrech)
#### Post date: [February 28, 2023, 6:51pm UTC](https://forum.remote.it/t/login-via-api-not-working/188/8 "2023-02-28T18:51:43Z")

</div>

Glad you are able to make your requests now.
