Twilio:列出连接的应用程序的电话号码 [英] Twilio: List phone numbers for connected app

查看:46
本文介绍了Twilio:列出连接的应用程序的电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我运行这个:

curl -X GET 'https://api.twilio.com/2010-04-01/Accounts/'$TWILIO_CONNECTED_APP_SID'/AuthorizedConnectApps/CN***.json' -u "$TWILIO_CONNECTED_APP_SID:$TWILIO_CONNECTED_AUTH_TOKEN" -sS | jq

我可以看到我的应用已获得授权:

I can see that my app is authorized:

{
  "connect_app_sid": "CN***",
  "account_sid": "AC***1",
  "permissions": [
    "get-all",
    "post-all"
  ],
  "connect_app_friendly_name": "*** Dev Connect App",
  "connect_app_description": "*** test account",
  "connect_app_company_name": "***",
  "connect_app_homepage_url": "https://***.com/",
  "uri": "/2010-04-01/Accounts/AC***/AuthorizedConnectApps/CN***.json"
}

但是当我尝试使用我的应用凭据列出该帐户的所有电话号码时:

But when I try to list all the phone numbers for that account using my app credentials:

curl -X GET 'https://api.twilio.com/2010-04-01/Accounts/'$TWILIO_CONNECTED_APP_SID'/IncomingPhoneNumbers.json' -u "$TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN" -sS | jq

我明白了:

{
  "code": 20003,
  "detail": "",
  "message": "Authenticate",
  "more_info": "https://www.twilio.com/docs/errors/20003",
  "status": 401
}

我不知道为什么.我知道这些凭据有效,因为我可以列出我的子帐户:

I can't figure out why. I know those credentials work because I can list my subaccounts:

curl -X GET 'https://api.twilio.com/2010-04-01/Accounts.json?Status=active' -u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN -sS | jq

我似乎无法获得我关联帐户的任何信息.

I just can't seem to get any info for my connected accounts.

推荐答案

Twilio 开发人员布道者在这里.

Twilio developer evangelist here.

当您代表通过 Twilio Connect 连接的帐户提出请求时,您应该使用连接帐户的 SID 和您的身份验证令牌对请求进行身份验证.帐户的 SID 也会进入 2010-04-01 命名空间下 API 请求的 URL.

When you make a request on behalf of an account that is connected through Twilio Connect you should authenticate the request with the connected account's SID but your auth token. The account's SID also goes into the URL for API requests under the 2010-04-01 namespace.

curl -X GET 'https://api.twilio.com/2010-04-01/Accounts/'$TWILIO_CONNECTED_APP_SID'/IncomingPhoneNumbers.json' \
 -u "$TWILIO_CONNECTED_APP_SID:$TWILIO_AUTH_TOKEN" -sS | jq

这篇关于Twilio:列出连接的应用程序的电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆