Skip to content

Add a way to generate access token from the CLI for automation purpose #17721

Closed
@mscherer

Description

@mscherer

Feature Description

It would be useful to me to be able to get a access token for a user in a way that would be easier to use by a external program (eg, automation with ansible or something else).

The current options to get a token are:

  • use the API (so I need a access token to generate a access token)
  • use the web interface (not very automation friendly)
  • generate a new user using gitea admin CLI, and parse the message, which is a bit fragile and only work with a new user.

So I would propose to add a subcommand to the admin user command:

$ gitea admin user generate-access-token --help
NAME:
   Gitea admin user generate-access-token - Generate a access token for a specific user

USAGE:
   Gitea admin user generate-access-token [command options] [arguments...]

OPTIONS:
   --username value, -u value     Username
   --token-name value, -t value   Token name (default: "gitea-admin")
   --raw                          Display only the token value
   --custom-path value, -C value  Custom path file path (default: "/tmp/custom")
   --config value, -c value       Custom configuration file path (default: "/tmp/custom/conf/app.ini")
   --version, -v                  print the version
   --work-path value, -w value    Set the gitea working path (default: "/tmp")
   

DEFAULT CONFIGURATION:
     CustomPath:  /tmp/custom 
     CustomConf:  /etc/gitea/app.ini
     AppPath:     /tmp/gitea
     AppWorkPath: /tmp

Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions