Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Can't create impersonation token from CLI #780

Copy link
Copy link
@jgeorgeson

Description

@jgeorgeson
Issue body actions

Description of the problem, including code/CLI snippet

Creation of user impersonation token fails from CLI with invalid scope error

$ gitlab -d -o json -g example user-impersonation-token create --user-id 168 --name test --scopes '["api"]'

It seems to be trying to pass the supplied value as a string instead of converting to an array (see the output in Actual Behavior). Have tried multiple variations of the scopes value such as api, [api], ["api"], "[api]", and "['api']".

Using curl like this

$ curl -X POST -H "Content-type: application/json" -H "PRIVATE-TOKEN: 123412341234" https://gitlab.example.com/api/v4/users/2/impersonation_tokens -d '{"name": "test", "scopes": ["api"]}'

Successfully creates the token.

Expected Behavior

Token is created.

Actual Behavior

send: b'POST /api/v4/users/2/impersonation_tokens HTTP/1.1\r\nHost: gitlab.example.com\r\nUser-Agent: python-requests/2.21.0\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nPRIVATE-TOKEN: 1234123412341234\r\nContent-type: application/json\r\nContent-Length: 55\r\n\r\n'
send: b'{"user_id": "2", "name": "test", "scopes": "[\'api\']"}'
reply: 'HTTP/1.1 400 Bad Request\r\n'
DEBUG:urllib3.connectionpool:https://gitlab.example.com:443 "POST /api/v4/users/2/impersonation_tokens HTTP/1.1" 400 29
Impossible to create object (400: scopes is invalid)
header: Server header: Date header: Content-Type header: Content-Length header: Connection header: Cache-Control header: Vary header: X-Content-Type-Options header: X-Frame-Options header: X-Request-Id header: X-Runtime 

Specifications

  • python-gitlab version: 1.8.0
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): 11.4.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.