条带使用角度http post连接身份验证

时间:2018-04-29 04:14:39

标签: angular post stripe-payments

我正在使用ng-file-upload指令将图像文件发送到我的角度控制器。 https://github.com/danialfarid/ng-file-upload

在我的角度控制器中,我试图将这个卷曲帖子从条带API文档转换为http帖子。 https://stripe.com/docs/connect/authentication

curl https://files.stripe.com/v1/files \
   -u {PLATFORM_SECRET_KEY}: \
   -H "Stripe-Account: {CONNECTED_STRIPE_ACCOUNT_ID}" \
   -F purpose=identity_document \
   -F file="@/path/to/a/file"

我的代码:

Upload.upload({
   url: "https://files.stripe.com/v1/files",
   method: "POST",
   headers: {
     "Authorization": "Bearer SK_Test_key",
     "Stripe-Account": "connected_acct_id",
      },
   data: {
     "purpose": "identity_document",
     file: file
    }
})...

这将返回401无效的api密钥

我搜索了stackoverflow,发现了一些不使用connect Angular and Stripe, Can't create Card token using $http, but can using CURL的条带http帖子示例 ,我觉得我的错误来自格式化。

阅读curl文档我知道-F代表“形式”,-H代表“标题”,-u代表“用户”,我尝试发送“user”:“sk_test_key”在标题之外和里面数据没有运气,与文件相同

0 个答案:

没有答案