Allow Creation of oauth2 User through the API #10729

Open
opened 2025-11-02 09:16:46 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @Louis39220 on GitHub (Apr 26, 2023).

Feature Description

I think it would be amazing if you could support oauth2 user's creation from the api.

Let say i would like to create a "Google" Gitea User, so when the user will log in with google it would link his account to the gitea user i created.

It's already supported through the WebUI cf screenshot

For example i would like to automate the user's creation this way :

  response = requests.post(
      f"{https://gitea.io/api/v1/admin/users}",
      json={
          "authenticationSource": "Google", (to override the default value: local)
          "visibility": "Private",
          "authenticationSigninName": google_id,
          "username": username,
          "email": email,
          "sendNotification": True
      },
      headers=headers,
      verify=False
  )

Thanks in advance 🙏

Screenshots

image

Originally created by @Louis39220 on GitHub (Apr 26, 2023). ### Feature Description I think it would be amazing if you could support **oauth2 user's creation from the api.** Let say i would like to create a "Google" Gitea User, so when the user will log in with google it would link his account to the gitea user i created. It's already supported through the WebUI cf screenshot For example i would like to automate the user's creation this way : ``` response = requests.post( f"{https://gitea.io/api/v1/admin/users}", json={ "authenticationSource": "Google", (to override the default value: local) "visibility": "Private", "authenticationSigninName": google_id, "username": username, "email": email, "sendNotification": True }, headers=headers, verify=False ) ``` Thanks in advance :pray: ### Screenshots ![image](https://user-images.githubusercontent.com/5887846/234627172-ea7ac019-c18b-458e-9623-cfe509f59e74.png)
GiteaMirror added the topic/apitype/proposaltype/feature labels 2025-11-02 09:16:46 -06:00
Author
Owner

@dianaStr7 commented on GitHub (May 3, 2023):

Would be a really helpful feature! In my case I'm trying to connect keycloack for authentication. For automatic user creation via API it needs an auth sourceID (which is possible to extract only manually from the Gitea UI). If I could assign an authentication source using its name - all problems solved. :)

@dianaStr7 commented on GitHub (May 3, 2023): Would be a really helpful feature! In my case I'm trying to connect keycloack for authentication. For automatic user creation via API it needs an auth sourceID (which is possible to extract only manually from the Gitea UI). If I could assign an authentication source using its name - all problems solved. :)
Author
Owner

@mattfysh commented on GitHub (Apr 6, 2024):

This test seems to show a way to do it

b2b49c9bde/tests/integration/admin_user_test.go (L52-L68)

@mattfysh commented on GitHub (Apr 6, 2024): This test seems to show a way to do it https://github.com/go-gitea/gitea/blob/b2b49c9bde63b311f01d500ada9212c46b9602fe/tests/integration/admin_user_test.go#L52-L68
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#10729