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

Receiving HTTP 403 errors against api.packet.net #135

Open
mristok opened this issue Feb 10, 2023 · 3 comments
Open

Receiving HTTP 403 errors against api.packet.net #135

mristok opened this issue Feb 10, 2023 · 3 comments

Comments

@mristok
Copy link

mristok commented Feb 10, 2023

I am encountering HTTP 403 with a verified valid token against the client package default API endpoint api.packet.net. I suspected that this is due to deprecation of the endpoint in favor of api.equinix.com.
Testing with the client endpoint changed (overridden) to api.equinix.com/metal/v1 indeed results is successful API calls with the client, however my testing was fairly limited in scope.

Please review if the api.packet.net endpoint is in fact deprecated, and make all necessary adjustments to account for (if necessary) the new appropriate endpoint.

@displague
Copy link
Member

@mristok api.equinix.com should be used, it is used in other integrations including ClusterAPI, Terraform, MetalCLI and the new Ansible Equinix collection.

In the Ansible Equinix collection we are using https://github.com/equinix-labs/metal-python/ (v0.1.0) / https://pypi.org/project/equinix-metal/.

This package is generated from the API spec so it is much more complete than packet-python.

@displague
Copy link
Member

Using the following local helper script, I didn't run into problems using api.packet.net:

#!/usr/bin/env bash
# emget: helper to GET Metal API requests. uses Metal CLI for auth defaults.

eval $(metal env)
P="$1"
DATA="$2"
METAL_API_URL="${METAL_API_URL:-https://api.equinix.com/metal/v1}"
CURL_OPT="${CURL_OPT:--s}"

curl ${CURL_OPT} -X GET \
    -H "X-Auth-Token: $METAL_AUTH_TOKEN" \
    -H "Content-Type: application/json" \
    "${METAL_API_URL}/$P" | jq .
$ METAL_API_URL=https://api.packet.net CURL_OPT="-s -v" emget /projects
...
> GET //projects HTTP/2
> Host: api.packet.net
> user-agent: curl/7.87.0
> accept: */*
> x-auth-token: ...
> content-type: application/json
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
< HTTP/2 200
...

@displague
Copy link
Member

All that aside, packet-python should get an update to api.equinix.com/metal/v1 and perhaps an environment variable way to override that ahead of any deprecation.

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

2 participants