我在Coinbase API之上编写了便利包装。 要求之一是获取所有用户帐户。
使用一组适当的作用域,并在成功进行OAuth身份验证之后,我可以使用/accounts
端点。
但是答案令人困惑:
{
"data": [
{
"id": "xxxx-xxxx-xxxx-xxxx",
"name": "BTC Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "BTC",
"name": "Bitcoin",
"color": "#F7931A",
"exponent": 8,
"type": "crypto",
"sort_index": 100,
"address_regex": "^([13][a-km-zA-HJ-NP-Z1-9]{25,34})|^(bc1([qpzry9x8gf2tvdw0s3jn54khce6mua7l]{39}|[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{59}))$"
},
"balance": {
"amount": "0.03115207",
"currency": "BTC"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "ETC",
"name": "ETC Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "ETC",
"name": "Ethereum Classic",
"color": "#59D4AF",
"exponent": 8,
"type": "crypto",
"sort_index": 103,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.00000000",
"currency": "ETC"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "ZRX",
"name": "ZRX Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "ZRX",
"name": "0x",
"color": "#302C2C",
"exponent": 8,
"type": "crypto",
"sort_index": 105,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.00000000",
"currency": "ZRX"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "BAT",
"name": "BAT Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "BAT",
"name": "Basic Attention Token",
"color": "#FF5000",
"exponent": 8,
"type": "crypto",
"sort_index": 106,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.00000000",
"currency": "BAT"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "USDC",
"name": "USDC Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "USDC",
"name": "USD Coin",
"color": "#2775CA",
"exponent": 6,
"type": "crypto",
"sort_index": 107,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.000000",
"currency": "USDC"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "ZEC",
"name": "ZEC Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "ZEC",
"name": "Zcash",
"color": "#ECB244",
"exponent": 8,
"type": "crypto",
"sort_index": 108,
"address_regex": "^(t1|t3)[a-km-zA-HJ-NP-Z1-9]{33}$"
},
"balance": {
"amount": "0.00000000",
"currency": "ZEC"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "DAI",
"name": "DAI Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "DAI",
"name": "Dai",
"color": "#FFB74D",
"exponent": 8,
"type": "crypto",
"sort_index": 115,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.00000000",
"currency": "DAI"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "LINK",
"name": "LINK Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "LINK",
"name": "Chainlink",
"color": "#0667D0",
"exponent": 8,
"type": "crypto",
"sort_index": 122,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.00000000",
"currency": "LINK"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "XRP",
"name": "XRP Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "XRP",
"name": "XRP",
"color": "#222222",
"exponent": 6,
"type": "crypto",
"sort_index": 125,
"address_regex": "^r[1-9a-km-zA-HJ-NP-Z]{25,35}$"
},
"balance": {
"amount": "0.000000",
"currency": "XRP"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "REP",
"name": "REP Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "REP",
"name": "Augur",
"color": "#553580",
"exponent": 8,
"type": "crypto",
"sort_index": 126,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.00000000",
"currency": "REP"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "XLM",
"name": "XLM Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "XLM",
"name": "Stellar Lumens",
"color": "#000000",
"exponent": 7,
"type": "crypto",
"sort_index": 127,
"address_regex": "^G[A-Z2-7]{55}$"
},
"balance": {
"amount": "0.0000000",
"currency": "XLM"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
}
]
端点返回不完整的用户帐户列表。我至少还有两个coinbase accounts
,余额为非零。
此外,ID不一致-对于BTC,我们已经设置了某种UUID,而其他钱包正在使用货币代码。
这使/transactions
终结点请求返回404,以尝试指向与BTC钱包不同的请求:
https://api.coinbase.com/v2/accounts/EOS/transactions
。
有什么想法可以获取完整的帐户列表,以及如何使用BTC钱包以外的ID?
我正在使用的范围:
("wallet:accounts:read",
"wallet:accounts:update",
"wallet:transactions:read",
"wallet:transactions:request",
"wallet:transactions:send");
我向一个钱包中添加了一笔交易,该交易已从下一个/accounts
请求中删除,这更加令人困惑。
答案 0 :(得分:2)
参考Coinbase文档https://developers.coinbase.com/docs/wallet/coinbase-connect/permissions
您可以将范围account = all
添加到权限范围。这将启用对所有硬币的读取访问权限
https://www.coinbase.com/oauth/authorize?response_type=code&client_id=YOUR_CLIENT_ID&account=all&redirect_uri=YOUR_CALLBACK_URL&scope=wallet:accounts:read,wallet:transactions:read
答案 1 :(得分:0)
经过一天的摸索,我终于找到了答案。
附加帐户是在单个钱包的基础上进行的。
用户需要分别添加BTC,XRP,ETC等帐户/钱包。 每个应用程序都收到带有访问和刷新令牌的自己的TokenResponse,您的应用程序需要对其进行管理。
仍然不了解在/accounts
端点id
无法使用的端点剩余帐户中返还的目的。