Ask Your Question
1

Need clarification on creation of V3 credentials

asked 2013-08-28 11:47:15 -0500

harika-vakadi gravatar image

While I was trying to create V3 credentials below was the issue faced

curl -i -X POST http://10.4.230.133:35357/v3/credentials -H "User-Agent: python-keystoneclient" -H "Content-Type: application/json" -H "X-Auth-Token: " -d'{"credential": {"user_id": "64d29e5d86f84440bdd8948ce81a5ae7", "blob": {"access": "bdd3ed90edee4cbf91d1ecdfc46", "secret": "47154b6378eb4b8685f75e4936e22"}, "project_id": "f06ea93f31be40f991154a63dedbf300", "type": "ec2"}}' HTTP/1.1 400 Bad Request Vary: X-Auth-Token Content-Type: application/json Content-Length: 89 Date: Wed, 28 Aug 2013 11:26:57 GMT

{"error": {"message": "Invalid blob in credential", "code": 400, "title": "Bad Request"}}

Request body I used to create is as below

body = {"credential": {"user_id": "64d29e5d86f84440bdd8948ce81a5ae7", "blob": {"access": "bdd3ed90edee4cbf91d1ecdfc46", "secret": "47154b6378eb4b8685f75e4936e22"}, "project_id": "f06ea93f31be40f991154a63dedbf300", "type": "ec2"}}

But this reference Doc ( https://github.com/openstack/identity-api/blob/master/openstack-identity-api/v3/src/markdown/identity-api-v3.md (https://github.com/openstack/identity...) ) says request to like this

Request: { "credential": { "blob": "--JSON serialized object containing 'access' and 'secret'--", "project_id": "--optional--", "type": "ec2", "user_id": "--user--id--" } }

Can anyone please correct me if I am wrong. ASAP.

Thanks in Advance, Harika.

edit retag flag offensive close merge delete

4 answers

Sort by ยป oldest newest most voted
0

answered 2013-08-29 10:59:00 -0500

harika-vakadi gravatar image

Thanks for your quick response Haneef

I have tried according to your suggestion, but resulted in error again.

Command I have tried is as below

curl -i -X POST http://10.4.230.133:35357/v3/credentials -H "User-Agent: python-keystoneclient" -H "Content-Type: application/json" -H "X-Auth-Token: " -d'{"credential": { "blob": "{"access": ,,, , "secret": "Secret-"}", "user_id": "64d29e5d86f84440bdd8948ce81a5ae7", "project_id": "f06ea93f31be40f991154a63dedbf300", "type": "ec2"}}' HTTP/1.1 400 Bad Request Vary: X-Auth-Token Content-Type: application/json Content-Length: 244 Date: Thu, 29 Aug 2013 10:36:06 GMT

{"error": {"message": "Expecting to find valid JSON in request body. The server could not comply with the request since it is either malformed or otherwise incorrect. The client is assumed to be in error.", "code": 400, "title": "Bad Request"}}

Other Request bodies I have tried are as below

---- {"credential": {"blob": '{\"access\": \"acceskey\", \"secret\": \"Secret\"}', "user_id": "64d29e5d86f84440bdd8948ce81a5ae7", "project_id": "f06ea93f31be40f991154a63dedbf300", "type": "ec2"}}

---- {"credential": {"blob": "{\"access\": \"acceskey\", \"secret\": \"Secret\"}", "user_id": "64d29e5d86f84440bdd8948ce81a5ae7", "project_id": "f06ea93f31be40f991154a63dedbf300", "type": "ec2"}}

---- {"credential": {"blob": "\{\"access\": \"acceskey\", \"secret\": \"Secret\"\}", "user_id": "64d29e5d86f84440bdd8948ce81a5ae7", "project_id": "f06ea93f31be40f991154a63dedbf300", "type": "ec2"}}

Can you please correct me if I am wrong.

Thanks in advance, Harika

edit flag offensive delete link more
0

answered 2013-08-28 22:33:29 -0500

haneef gravatar image

blob = json serialized string . Someting like blob: " { "acess" : ,,, , "secret": "xxxx"}"

(i.e) blob = Within quotes some strng which is in json format. What you have is

edit flag offensive delete link more
0

answered 2013-08-29 22:09:11 -0500

haneef gravatar image

from the code

try: blob = json.loads(ref.get('blob')) except (ValueError, TypeError):

So basically when you construct the request try to load the blob from the request. If it works then request to keystone will also work

do the following in a small python program

cred = {} cred["credential" = {} cred["credential"]["type"] = "ec2" cred["credential"]["user_id"] = < user id> cred["credential"]["poject_id"] = < project id>

blob = {} blob["access"] = "some key" blob["secret" ] = "some key"

cred["credential"]["blob"] = json.dumps(blob)

print cred

You can use this output. If you are using via curl make sure you escape every place. I believe you only need to escape inner quotes. Something like

{"a": 1, "blob": "{\"b\": \"1\"}"}

edit flag offensive delete link more
0

answered 2013-09-03 05:52:02 -0500

harika-vakadi gravatar image

Thanks Haneef Ali, that solved my question.

edit flag offensive delete link more

Comments

Could you please post what exactly worked ? I am getting the same error !

Shankar.mj gravatar imageShankar.mj ( 2014-08-25 13:37:52 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2013-08-28 11:47:15 -0500

Seen: 246 times

Last updated: Sep 03 '13