1

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?

4

3 回答 3

1

我就这个问题联系了 truevault 支持。丹帮助我度过了难关。

我将用户名/密码/account_id 作为 url 字符串查询参数传递。我必须对代码进行两处更改: 1. 将上述内容作为表单数据参数传递 2. 将 angular-post-fix.js 添加到我的项目中。(注意:我没有添加链接,因为有些编辑会禁止发布带有其他地方链接的帖子。过去发生过!)

于 2015-02-26T08:13:14.203 回答
0

@orthodoc 是对的,但是如何实际构建请求有点棘手。假设我们正在使用带有formData参数的fetch,我想添加一个成功请求的示例:

...
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
});
...
于 2016-06-11T00:07:43.780 回答
0

使用 Node.js 时,querystringAPI 非常有用。只需将对象传递给querystring.stringify()函数,结果输出就可以发送到 TrueVault 进行登录。

此外,我发现添加标头'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'可能是必要的(这是 Angular 后修复库所做的事情之一)。

于 2016-02-02T04:26:48.537 回答