Reputation: 31
On attempting to login via the truvault api using angular js, I am getting this error message: Failed to parse UUID. I am passing the username, password and account_id as params. I am successful using the curl command and get the success response.
The 400 error is not described in the api docs for authorization. I am not sure about if this UUID is linked to the schema_id. Would anyone (truevault guys!!) know what I am doing wrong?
Upvotes: 1
Views: 2077
Reputation: 623
@orthodoc is right, but is kind of tricky how to actually build the request. Lets say we are using fetch with formData params, I'd like to add an example of a successful request:
...
var formData = new FormData();
formData.append('username', username);
formData.append('password', password);
formData.append('account_id', accountId);
return fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
},
body: formData
});
...
Upvotes: 0
Reputation: 159
When using Node.js, the querystring
API is really useful. Just pass an object to the querystring.stringify()
function, and the resulting output is ready to be sent to TrueVault for login.
Additionally, I found that adding the header 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
might be necessary (which is one of the things the Angular post-fix library does).
Upvotes: 0
Reputation: 31
I contacted truevault support on this one. Dan helped me get through it.
I was passing the username/password/account_id as url string query parameters. I had to make two changes to the code: 1. Pass the above as form data parameters 2. add the angular-post-fix.js to my project. (Note: I am not adding the link as there are editors who will disallow the post with links to elsewhere. It has happened in the past!)
Upvotes: 1