Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on OS 3.4 -- asyncio.run(account.getAccountBearerToken()) #23

Closed
umoraes opened this issue Oct 22, 2023 · 2 comments
Closed

Error on OS 3.4 -- asyncio.run(account.getAccountBearerToken()) #23

umoraes opened this issue Oct 22, 2023 · 2 comments

Comments

@umoraes
Copy link

umoraes commented Oct 22, 2023

hi... I'm running a C4 EA1 OS 3.4 and my first test.py to test the controller to list all devices, I get this error:

Exception has occurred: BadCredentials
{"C4ErrorResponse":{"code":401,"details":"Permission denied Bad credentials","message":"Permission denied","subCode":0}}
File "C:\tmp\C4\2\a.py", line 14, in
asyncio.run(account.getAccountBearerToken())
pyControl4.error_handling.BadCredentials: {"C4ErrorResponse":{"code":401,"details":"Permission denied Bad credentials","message":"Permission denied","subCode":0}}

I'm using root users on python... password is correct (I changed it to t0talc0ntr0l4! since its lower than 40 letters.

asyncio.run(account.getAccountBearerToken()) is where I get error.

Is there something that needs to be configured in addition to username, password and ip? Is there a C4 drive needed to use this code?

I'm using the basic code... here it's:

from pyControl4.account import C4Account
from pyControl4.director import C4Director
from pyControl4.light import C4Light
import asyncio
import json

username = "root"
password = "t0talc0ntr0l4!"
ip = "192.168.1.23" # Substitua pelo endereço IP do seu Control4 Director

"""Authenticate with Control4 account"""
account = C4Account(username, password)
asyncio.run(account.getAccountBearerToken())

"""Get and print controller name"""
accountControllers = asyncio.run(account.getAccountControllers())
print(accountControllers["controllerCommonName"])

"""Get bearer token to communicate with controller locally"""
director_bearer_token = asyncio.run(
account.getDirectorBearerToken(accountControllers["controllerCommonName"])
)["token"]

"""Create new C4Director instance"""
director = C4Director(ip, director_bearer_token)

"""Print all devices on the controller"""
print(asyncio.run(director.getAllItemInfo()))

"""Create new C4Light instance"""
light = C4Light(director, 253)

"""Ramp light level to 10% over 10000ms"""
asyncio.run(light.rampToLevel(10, 10000))

"""Print state of light"""
print(asyncio.run(light.getState()))

@nicgraner
Copy link

your account credentials are needed, not the credentials for the controller, so whatever you use to log in to the control4 app is what you should have instead of root and total control.

@umoraes
Copy link
Author

umoraes commented Nov 13, 2023 via email

@lawtancool lawtancool closed this as not planned Won't fix, can't repro, duplicate, stale Nov 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants