Hi all, I'm half expecting this to be my misunderstanding, but I'm having problems getting authorised to the point of getting access to my account data.
I am able to authenticate using my credentials, and enter my 2FA code, but have not been able to keep access when my original token expires.
I can register a trusted device with this, and it shows up in my account in the app:
auth = Hive.Auth(username, password)
authData = auth.login()
if authData.get("ChallengeName") == "SMS_MFA":
code = input("Enter your 2FA code: ")
authData = auth.sms_2fa(code, authData).get('AuthenticationResult') # assumes all was OK
auth.device_registration('MyTrustedDevice')
accessToken = authData['AccessToken']
refreshToken = authData['RefreshToken']
idToken = authData['IdToken']
deviceKey = authData['NewDeviceMetadata']['DeviceKey']
deviceGroupKey = authData['NewDeviceMetadata']['DeviceGroupKey']
devicePassword = auth.device_password
Then I am able to authenticate again using these pieces of information, and have the returned tokens:
auth = Hive.Auth(username, password, deviceGroupKey, deviceKey, devicePassword)
authData = auth.device_login().get('AuthenticationResult') # assumes all was OK
accessToken = authData['AccessToken']
refreshToken = authData['RefreshToken']
idToken = authData['IdToken']
But I don't see how I'm supposed to get the data out?
The API example suggests I can just use my idToken:
api = Hive.HiveApi(token=idToken)
data = api.getAll()
However, I get a not authorised resposne:
{
"original": 401,
"parsed": {
"error": "NOT_AUTHORIZED"
}
}
Alternatively, the Session example suggests I can authenticate a different way with my device credentials:
from pyhiveapi import Hive, SMS_REQUIRED
session = Hive(
username="<Hive Username>",
password="<Hive Password>",
deviceGroupKey="<Hive Device Group Key>",
deviceKey="<Hive Device Key>",
devicePassword="<Hive Device Password>",
)
session.deviceLogin()
session.startSession()
This raises an exception:
Original exception was:
Traceback (most recent call last):
File "/Users/jon/Repo/hivereader/./another.py", line 12, in <module>
session = Hive(
TypeError: __init__() got an unexpected keyword argument 'deviceGroupKey'
I don't see what I can pass the device info to that will then be able to use my token?
Again, sorry if this is just user error!
Hi all, I'm half expecting this to be my misunderstanding, but I'm having problems getting authorised to the point of getting access to my account data.
I am able to authenticate using my credentials, and enter my 2FA code, but have not been able to keep access when my original token expires.
I can register a trusted device with this, and it shows up in my account in the app:
Then I am able to authenticate again using these pieces of information, and have the returned tokens:
But I don't see how I'm supposed to get the data out?
The API example suggests I can just use my idToken:
However, I get a not authorised resposne:
{ "original": 401, "parsed": { "error": "NOT_AUTHORIZED" } }Alternatively, the Session example suggests I can authenticate a different way with my device credentials:
This raises an exception:
I don't see what I can pass the device info to that will then be able to use my token?
Again, sorry if this is just user error!