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

Cannot retrieve project with project api key #245

Open
chris-rock opened this issue Mar 6, 2021 · 4 comments
Open

Cannot retrieve project with project api key #245

chris-rock opened this issue Mar 6, 2021 · 4 comments
Labels

Comments

@chris-rock
Copy link

I try to get the project information for a project api key:

os.Setenv("PACKET_AUTH_TOKEN", "PROJECT_API_KEY")

c, err := packngo.NewClient()
require.NoError(t, err)

project, _, err := c.Projects.Get("PROJECT_ID", nil)
require.NoError(t, err)
log.Println(project)

This always throws an 401 error. If I use c.Projects.List it returns the project. Is that behavior intended?

I try to implement a similar behavior as your terraform provider https://github.com/packethost/terraform-provider-packet/blob/master/packet/datasource_packet_project.go#L116-L122. I wonder if this works with project api keys?

@t0mk
Copy link
Contributor

t0mk commented Mar 7, 2021

Hi @chris-rock, Thanks for the report. I verified and it's true.

When I use project API key and call c.Projects.List(nil), I will get the project record in the result slice, and there will be only the parent project of the API key.

But when I try to do c.Projects.Get(project_id, nil) with auth token from project with ID project_id, the Metal API will return 404 Not Found.

It would make sense for the c.Project.Get(project_id, nil) to succeed for the parent project of the API Key.

This is an API bug. @displague can you please bring to attention of API devs?

@t0mk t0mk added the api bug label Mar 7, 2021
@chris-rock
Copy link
Author

@t0mk Thank you for confirming. The same happens with a get calls for an Organization

@displague
Copy link
Member

I will raise the issue of the GET /projects/{id} not working with Project API keys, especially despite GET /projects working.

I can understand a project scoped key not revealing organization level details, what is your use-case, @chris-rock?

@chris-rock
Copy link
Author

Oh I was just thinking that we could get the org details of a project since the API returns the organization url as part of the project fetch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants