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!