Plaid API 获取访问令牌 java android
我是与 API 通信的初学者,目前正在使用 Plaid API 来检索 Android 应用程序的交易数据。目前,我已成功与 Plaid Link 集成,并且可以通过应用程序获取公共令牌,但是我现在在将公共令牌交换为访问令牌时遇到问题。我从这里获取公共令牌:
private ActivityResultLauncher<LinkTokenConfiguration> linkAccountToPlaid = registerForActivityResult(
new OpenPlaidLink(),
result -> {
if (result instanceof LinkSuccess) {
//Exchange public token for persistent access token
我相信服务器上的以下代码用于交换公共令牌:
app.post('/api/set_access_token', function (request, response, next) {
PUBLIC_TOKEN = request.body.public_token;
Promise.resolve()
.then(async function () {
const tokenResponse = await client.itemPublicTokenExchange({
public_token: PUBLIC_TOKEN,
});
prettyPrintResponse(tokenResponse);
ACCESS_TOKEN = tokenResponse.data.access_token;
ITEM_ID = tokenResponse.data.item_id;
if (PLAID_PRODUCTS.includes('transfer')) {
TRANSFER_ID = await authorizeAndCreateTransfer(ACCESS_TOKEN);
}
response.json({
access_token: ACCESS_TOKEN,
item_id: ITEM_ID,
error: null,
});
})
.catch(next);
});
我正在运行快速启动服务器,我的问题是,如何调用服务器来交换公共令牌对于访问令牌?或者换句话说,如何进行后调用,其中包含服务器的公共令牌以接收访问令牌
I am a beginner with communicating with APIs and I am currently working with the Plaid API in order to retrieve transaction data for an android application. Currently, I have successfully integrated with the Plaid Link and can obtain public tokens through the app, however I am now having trouble exchanging the public token for the access token. I obtain the public token from here:
private ActivityResultLauncher<LinkTokenConfiguration> linkAccountToPlaid = registerForActivityResult(
new OpenPlaidLink(),
result -> {
if (result instanceof LinkSuccess) {
//Exchange public token for persistent access token
I believe the following code on the server is used to exchange the public token:
app.post('/api/set_access_token', function (request, response, next) {
PUBLIC_TOKEN = request.body.public_token;
Promise.resolve()
.then(async function () {
const tokenResponse = await client.itemPublicTokenExchange({
public_token: PUBLIC_TOKEN,
});
prettyPrintResponse(tokenResponse);
ACCESS_TOKEN = tokenResponse.data.access_token;
ITEM_ID = tokenResponse.data.item_id;
if (PLAID_PRODUCTS.includes('transfer')) {
TRANSFER_ID = await authorizeAndCreateTransfer(ACCESS_TOKEN);
}
response.json({
access_token: ACCESS_TOKEN,
item_id: ITEM_ID,
error: null,
});
})
.catch(next);
});
I have the quickstart server running, my question is, how do I then make the call to the server to exchange the public token for the access token? or in other words, how do I make a post call, containing the public token to the server to receive the access token
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Plaid Android 团队的回应:
因此,在我们的 GitHub 上的 Android 快速入门示例中,我们已经设置 Retrofit API 来检索
link_token
。你想要做的是添加类似的东西
Response from the Plaid Android team:
So in our Android quickstart sample on GitHub, we already have a Retrofit API set up to retrieve the
link_token
.What you would want to do is to add something like