Title: Can't create impersonation token from CLI · Issue #780 · python-gitlab/python-gitlab · GitHub
Open Graph Title: Can't create impersonation token from CLI · Issue #780 · python-gitlab/python-gitlab
X Title: Can't create impersonation token from CLI · Issue #780 · python-gitlab/python-gitlab
Description: 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"...
Open Graph Description: 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 --...
X Description: 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 --...
Opengraph URL: https://github.com/python-gitlab/python-gitlab/issues/780
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Can't create impersonation token from CLI","articleBody":"## Description of the problem, including code/CLI snippet\r\n\r\nCreation of user impersonation token fails from CLI with invalid scope error\r\n\r\n```bash\r\n$ gitlab -d -o json -g example user-impersonation-token create --user-id 168 --name test --scopes '[\"api\"]'\r\n```\r\nIt 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']\"`.\r\n\r\nUsing curl like this\r\n\r\n```bash\r\n$ 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\"]}'\r\n```\r\nSuccessfully creates the token.\r\n\r\n## Expected Behavior\r\n\r\nToken is created.\r\n\r\n## Actual Behavior\r\n\r\n```bash\r\nsend: 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'\r\nsend: b'{\"user_id\": \"2\", \"name\": \"test\", \"scopes\": \"[\\'api\\']\"}'\r\nreply: 'HTTP/1.1 400 Bad Request\\r\\n'\r\nDEBUG:urllib3.connectionpool:https://gitlab.example.com:443 \"POST /api/v4/users/2/impersonation_tokens HTTP/1.1\" 400 29\r\nImpossible to create object (400: scopes is invalid)\r\nheader: 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 \r\n```\r\n\r\n## Specifications\r\n\r\n - python-gitlab version: 1.8.0\r\n - API version you are using (v3/v4): v4\r\n - Gitlab server version (or gitlab.com): 11.4.4\r\n","author":{"url":"https://github.com/jgeorgeson","@type":"Person","name":"jgeorgeson"},"datePublished":"2019-05-23T14:57:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/780/python-gitlab/issues/780"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ae9a6933-63ad-16aa-6478-152c9e2c0c88 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AE3A:33119C:2C36CF:3E9406:69724310 |
| html-safe-nonce | 2c9daf5d065c9da9c4001aff49df045eb825ddb38b7e528fd5c2f387fc516af1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTNBOjMzMTE5QzoyQzM2Q0Y6M0U5NDA2OjY5NzI0MzEwIiwidmlzaXRvcl9pZCI6IjU5NTE3MjY3MzQzNTUzNTAyODgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d90824d8539e0329bedfa63327e0efe488ed191985c94cdf124ddc82e0d1951b |
| hovercard-subject-tag | issue:447713178 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-gitlab/python-gitlab/780/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1d787a7f2fdc7a2a408751510283f7335ca2d4766644ff7c29242452011baf6b/python-gitlab/python-gitlab/issues/780 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1d787a7f2fdc7a2a408751510283f7335ca2d4766644ff7c29242452011baf6b/python-gitlab/python-gitlab/issues/780 |
| og:image:alt | 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 --... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jgeorgeson |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2c16db4e575031f6e3be03e0437c1ab663e0b4643ba5cbbfba48c1e4fc056a11 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-gitlab/python-gitlab git https://github.com/python-gitlab/python-gitlab.git |
| octolytics-dimension-user_id | 28886265 |
| octolytics-dimension-user_login | python-gitlab |
| octolytics-dimension-repository_id | 8077625 |
| octolytics-dimension-repository_nwo | python-gitlab/python-gitlab |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 8077625 |
| octolytics-dimension-repository_network_root_nwo | python-gitlab/python-gitlab |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 584fea6daacd0ba6f8dbec869937910ee0ae2e64 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width