Problems with Creating SSH Public Keys via the API
gunit84 opened this issue · 4 comments
Hi Guys using GOGS in docker (Gogs Version: 0.11.6.0407), trying to use the API , to create SSH Public Keys:
- I have created API Token and can confirm that I can create repositories using the API
I run the command to attempt to create keys:
curl -k -H "Content-Type: application/json" -d '{
"title": "Test SSH Keys",
"key": "test" }' -X POST https://test.rap.local:3000/api/v1/user/repos?token=6d836a020e19be4ce8952154969c8b6644f1e53a
-
This is the error I get:
[{"fieldNames":["Name"],"classification":"RequiredError","message":"Required"} -
So I then added, a Name field in hope:
curl -k -H "Content-Type: application/json" -d '{
"title": "Test SSH Keys",
"Name": "test",
"key": "test" }' -X POST https://test.rap.local:3000/api/v1/user/repos?token=6d836a020e19be4ce8952154969c8b6644f1e53a
It then created a new repository with no keys.
I am going of the documentation here:
https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys In the Create a public key section.
The documentation was last updated Dec 6, 2015, have there been any changes to the syntax?
Thanks for your time and help.
Hi, I don't think you're calling the correct API end point. It is POST /user/keys not POST /user/repos.
Hi This does not make a difference:
vim test_key
{
"title": "Test SSH Keys",
"key": "wms01.rap.local ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvGpY3535ff4DpZFOz4I+8VoQaiHhIEWmolu+Oj01NYJOktFc5QbLgVmq4s7B8utwP78YlSGHdi8CjTXXR9K/RaRzFtBjz6jSsXXUkZJdG0M8cmaUQ0ZxhWFYRjvy9R5AxXBwJ3marh3kJFnJEEN9EYUsguvaVNq8hdcaalOJYhBc3AY0oe9/BkVahpEERgvmAILXjGJOQSD9Z8o91ImJBIAdbriyNlGES35gWk/Lqh+15u++sO3Qk8e8wnm2BQyHqlm0/kGbgFiB0ustcS+tfYQrNJht1TwZDIPqPa9pjZgIShGm1g8Xvtf7mSKoMgrWZnnnZCovh2DMAw29zjolKUylw=="
}
curl -k -H "Content-Type: application/json" --data-binary "@/etc/ansible/test_key" -X POST https://test.server.local:3000/api/v1/user/keys?token=6d836a020e19be4ce8952154969c8b6644f1e53a
error:
{"message":"Invalid key content: extractTypeFromBase64Key: invalid key format: illegal base64 data at input byte 3","url":"https://github.com/gogits/go-gogs-client/wiki"}
Thanks
Hi This does not make a difference:
Calling wrong end point you define as "not make a difference"? If you post error without second think, that is indeed does not make any difference.
invalid key format: illegal base64 data at input byte 3
I think the error is more than clear.
Try:
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvGpY3535ff4DpZFOz4I+8VoQaiHhIEWmolu+Oj01NYJOktFc5QbLgVmq4s7B8utwP78YlSGHdi8CjTXXR9K/RaRzFtBjz6jSsXXUkZJdG0M8cmaUQ0ZxhWFYRjvy9R5AxXBwJ3marh3kJFnJEEN9EYUsguvaVNq8hdcaalOJYhBc3AY0oe9/BkVahpEERgvmAILXjGJOQSD9Z8o91ImJBIAdbriyNlGES35gWk/Lqh+15u++sO3Qk8e8wnm2BQyHqlm0/kGbgFiB0ustcS+tfYQrNJht1TwZDIPqPa9pjZgIShGm1g8Xvtf7mSKoMgrWZnnnZCovh2DMAw29zjolKUylw==
Thank you and apologies for incompetence!