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

failed to initialize provider, error: failed creating Gitea client: 403 Forbidden #580

Closed
viceice opened this issue Jul 19, 2023 · 15 comments · Fixed by #583
Closed

failed to initialize provider, error: failed creating Gitea client: 403 Forbidden #580

viceice opened this issue Jul 19, 2023 · 15 comments · Fixed by #583

Comments

@viceice
Copy link

viceice commented Jul 19, 2023

Since Gitea upgrade from v1.19 to v1.20 i get this error. 😕

failed to initialize provider, error: failed creating Gitea client: 403 Forbidden

return nil, fmt.Errorf("failed creating Gitea client: %w", err)

I know they changed the api key scopes1, but the key still has repo write scope. My current key was created on v1.19.x with repo scope.
It had these scopes:

  • repo
  • repo:status
  • read:package

It's now converted to these scopes:

  • read:package
  • write:repository

Gitea log message:

2023/07/21 06:48:51 ...eb/routing/logger.go:102:func1() [I] router: completed GET /api/v1/version for a.b.c.d:0, 403 Forbidden in 58.3ms @ v1/api.go:242(v1.tokenRequiresScopes)

Please let me know how to debug this futher. Are there any option to pass additional debug messages?

Footnotes

  1. https://blog.gitea.com/release-of-1.20.0/#%EF%B8%8F-refactored-scoped-tokens-mechanism-24767

@makkes
Copy link
Member

makkes commented Jul 19, 2023

What is the exact error you're getting? I just upgrade to Gitea 1.20 and it's working fine with an existing token.

@viceice
Copy link
Author

viceice commented Jul 19, 2023

there is no other error. btw the apikey had repo scope only before the Gitea upgrade and was working fine.

btw: I also updated flux from v2 rc to v2.0.1 today. maybe there has something changed too?

@makkes
Copy link
Member

makkes commented Jul 19, 2023

there is no other error.

You still haven't pasted the error you're seeing into this issue. The only thing you did was post a link to the source code where that error supposedly originates. Pasting the actual error you're seeing may help understanding what's causing it.

btw: I also updated flux from v2 rc to v2.0.1 today. maybe there has something changed too?

I tried 2.0.1 and didn't run into any issues.

@viceice
Copy link
Author

viceice commented Jul 19, 2023

sorry, the error is the issue title

@viceice
Copy link
Author

viceice commented Jul 19, 2023

btw: I also updated flux from v2 rc to v2.0.1 today. maybe there has something changed too?

I tried 2.0.1 and didn't run into any issues.

Are you using a token with full rights or a repo scoped?

Did you created the token before updating Gitea to v1.20?

@makkes
Copy link
Member

makkes commented Jul 20, 2023

btw: I also updated flux from v2 rc to v2.0.1 today. maybe there has something changed too?

I tried 2.0.1 and didn't run into any issues.

Are you using a token with full rights or a repo scoped?

Did you created the token before updating Gitea to v1.20?

I created the Token on Gitea 1.18 so there was no way to choose its scope. After the upgrade to 1.20 it shows this scope:

Repository and Organization Access: All (public, private, and limited)
Permissions:
    all

@viceice
Copy link
Author

viceice commented Jul 20, 2023

so it seems to be an issue with the scopes, as the same token works fine for fetching the repo from flux.

maybe some new scope is needed to initialize the Gitea client. do you know which calls it does ?

will also check the Gitea logs to hopefully find the failed requests.

@makkes
Copy link
Member

makkes commented Jul 20, 2023

What scope does the token you use (the one that doesn't work) have?

@makkes
Copy link
Member

makkes commented Jul 20, 2023

@viceice Please supply as much information as possible on your issue and environment. Otherwise we will have to ask for each and every bit of information and won't be able to make any reasonable progress getting to the bottom of your problem.

@viceice
Copy link
Author

viceice commented Jul 20, 2023

ok, will extend the issue description tomorrow

@viceice
Copy link
Author

viceice commented Jul 21, 2023

Updated body. It seems the /api/v1/version isn't allowed with that token. 😕

@viceice
Copy link
Author

viceice commented Jul 21, 2023

It seems we now need misc scope
image

@makkes
Copy link
Member

makkes commented Jul 21, 2023

That is indeed interesting. We should definitely document the necessary minimum scopes. Thanks for digging into this. I just verified that the following scopes are necessary to make the provider work:

  • read:misc
  • write:repository

@viceice
Copy link
Author

viceice commented Jul 21, 2023

yes, I've added read:packages to allow flux fetching docker / oci stuff from Gitea 😉

makkes pushed a commit that referenced this issue Jul 22, 2023
closes #580

Signed-off-by: Max Jonas Werner <mail@makk.es>
@viceice
Copy link
Author

viceice commented Jul 29, 2023

it seems misc is no longer necessary since v1.20.2

go-gitea/gitea#26035

makkes pushed a commit that referenced this issue Jul 31, 2023
closes #580

Signed-off-by: Max Jonas Werner <mail@makk.es>
makkes pushed a commit that referenced this issue Jul 31, 2023
closes #580

Signed-off-by: Max Jonas Werner <mail@makk.es>
makkes pushed a commit that referenced this issue Jul 31, 2023
closes #580

Signed-off-by: Max Jonas Werner <mail@makk.es>
makkes pushed a commit that referenced this issue Jul 31, 2023
closes #580

Signed-off-by: Max Jonas Werner <mail@makk.es>
makkes pushed a commit that referenced this issue Jul 31, 2023
closes #580

Signed-off-by: Max Jonas Werner <mail@makk.es>
makkes pushed a commit that referenced this issue Jul 31, 2023
closes #580

Signed-off-by: Max Jonas Werner <mail@makk.es>
makkes pushed a commit that referenced this issue Aug 3, 2023
closes #580

Signed-off-by: Max Jonas Werner <mail@makk.es>
github-actions bot pushed a commit that referenced this issue Aug 3, 2023
closes #580

Signed-off-by: Max Jonas Werner <mail@makk.es>
(cherry picked from commit e1d3a59)
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

Successfully merging a pull request may close this issue.

2 participants