iamkubi / pydactyl

Python wrapper for the Pterodactyl Panel API
MIT License
69 stars 21 forks source link

403 error. #65

Closed AutiCodes closed 1 year ago

AutiCodes commented 1 year ago

Hi, when i make an new user, everything works fine without issues. Code:

from pydactyl import PterodactylClient

# Create a client to connect to the panel and authenticate with your API key.
api = PterodactylClient('http://10.10.10.5/', 'API key here!')

result = api.user.create_user('test', 'test212@gmail.com', 'Test21', 'Name')

user_id = result['attributes']['id']

api.user.get_user_info(user_id)
{'object': 'user', 'attributes': {'id': 14, 'external_id': None}}

But when i use:

from pydactyl import PterodactylClient

# Create a client to connect to the panel and authenticate with your API key.
api = PterodactylClient('http://10.10.10.5/', 'API key here!')

# Get a list of all servers the user has access to
my_servers = api.client.servers.list_servers()
# Get the unique identifier for the first server.
srv_id = my_servers[0]['attributes']['identifier']

# Check the utilization of the server
srv_utilization = api.client.servers.get_server_utilization(srv_id)
print(srv_utilization)

# Turn the server on.
api.client.servers.send_power_action(srv_id, 'start')

I get: requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: http://10.10.10.5/api/client

I have everything on read/write. Can you help me?

iamkubi commented 1 year ago

You can't use Application API keys for client endpoints. You have to use a Client API key.

crocofied commented 7 months ago

You can't use Application API keys for client endpoints. You have to use a Client API key.

How to get a client api key