Login via API not working

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

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

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

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!

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 .
I appreciate any help!

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

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

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!

1 Like

Glad you are able to make your requests now.