Commit b558ba51 authored by Evan Read's avatar Evan Read

Merge branch 'psureshbabu-master-patch-58118' into 'master'

Doc | Add note about user permissions for creating group access tokens

See merge request gitlab-org/gitlab!76744
parents 8276067f 67516f14
...@@ -109,14 +109,26 @@ To create a group access token: ...@@ -109,14 +109,26 @@ To create a group access token:
1. Run the following commands in a [Rails console](../../../administration/operations/rails_console.md): 1. Run the following commands in a [Rails console](../../../administration/operations/rails_console.md):
```ruby ```ruby
admin = User.find(1) # group admin # Set the GitLab administration user to use. If user ID 1 is not available or is not an adinistrator, use 'admin = User.admins.first' instead to select an admininistrator.
group = Group.find(109) # the group you want to create a token for admin = User.find(1)
bot = Users::CreateService.new(admin, { name: 'group_token', username: "group_#{group.id}_bot", email: "group_#{group.id}_bot@example.com", user_type: :project_bot }).execute # create the group bot user
# for further group access tokens, the username should be group_#{group.id}_bot#{bot_count}, e.g. group_109_bot2, and their email should be group_109_bot2@example.com # Set the group group you want to create a token for. For example, group with ID 109.
bot.confirm # confirm the bot group = Group.find(109)
group.add_user(bot, :maintainer) # add the bot to the group at the desired access level
token = bot.personal_access_tokens.create(scopes:[:api, :write_repository], name: 'group_token') # give it a PAT # Create the group bot user. For further group access tokens, the username should be group_#{group.id}_bot#{bot_count}. For example, group_109_bot2 and email address group_109_bot2@example.com.
gtoken = token.token # get the token value bot = Users::CreateService.new(admin, { name: 'group_token', username: "group_#{group.id}_bot", email: "group_#{group.id}_bot@example.com", user_type: :project_bot }).execute
# Confirm the group bot.
bot.confirm
# Add the bot to the group with the required role.
group.add_user(bot, :maintainer)
# Give the bot a personal access token.
token = bot.personal_access_tokens.create(scopes:[:api, :write_repository], name: 'group_token')
# Get the token value.
gtoken = token.token
``` ```
1. Test if the generated group access token works: 1. Test if the generated group access token works:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment