SetSudo not working when creating access token #10645

Open
opened 2025-11-02 09:14:08 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @whybeyoung on GitHub (Apr 13, 2023).

Description

Usecase:

i have admin accessstoken, and i new the client by setting this token. Now i have many users, and i want to help them create their own access token, so i want to use admin to on behalf them, i use setSudo , but not success..

i get message

"\"username\" not set: only BasicAuth allowed"

my client code is :

cli := gitea.NewClient(GetGitServer(), gitea.SetToken(xx),gitea.SetSudo(user1))
at, resp, err := cli.CreateAccessToken(option)

Gitea Version

1.19

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

linux

How are you running Gitea?

docker-compose up -d

Database

MySQL

Originally created by @whybeyoung on GitHub (Apr 13, 2023). ### Description Usecase: i have admin accessstoken, and i new the client by setting this token. Now i have many users, and i want to help them create their own access token, so i want to use admin to on behalf them, i use setSudo , but not success.. i get message ```json "\"username\" not set: only BasicAuth allowed" ``` my client code is : ```golang cli := gitea.NewClient(GetGitServer(), gitea.SetToken(xx),gitea.SetSudo(user1)) at, resp, err := cli.CreateAccessToken(option) ``` ### Gitea Version 1.19 ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System linux ### How are you running Gitea? docker-compose up -d ### Database MySQL
GiteaMirror added the type/bug label 2025-11-02 09:14:08 -06:00
Author
Owner

@yp05327 commented on GitHub (Apr 20, 2023):

As the error info said, only BasicAuth allowed.
So use SetBasicAuth instead of SetToken when create gitea client?

ps: maybe this issue should move to https://gitea.com/gitea/go-sdk ?
It seems that this issue requests for Support OAuth2 when create gitea client

@yp05327 commented on GitHub (Apr 20, 2023): As the error info said, `only BasicAuth allowed`. So use `SetBasicAuth` instead of `SetToken` when create gitea client? ps: maybe this issue should move to https://gitea.com/gitea/go-sdk ? It seems that this issue requests for `Support OAuth2 when create gitea client`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10645