格子 ruby gem:交换令牌抛出 'provided public token is in an invalid format' 错误
plaid ruby gem: exchange token throwing 'provided public token is in an invalid format' error
我在 React 中使用 Link 将 link 传递给 Items,然后将 public_token 传递到我的 rails 服务器,我试图在其中交换 public 访问令牌的令牌。 Link 成功将 public 令牌返回给我,它看起来像 public-sandbox-6df92f82-3260-4cb4-8489-65e6ac955e7a
我正在将其传递到我的 rails 服务器,我在服务器上使用格子-ruby gem 尝试交换代币。但是,我收到 INVALID_INPUT
错误。
格子-ruby码(params["plaidToken"] == public-sandbox-6df92f82-3260-4cb4-8489-65e6ac955e7a
):
def set_plaid_token
client = Plaid::Client.new(env: :sandbox,
client_id: '*******',
secret: '*******',
public_key: params["plaidToken"])
exchange_token_response = client.item.public_token.exchange('[Plaid Link public_token]')
access_token = exchange_token_response.access_token
#TODO users can add same bank twice.
user = UserToken.find_by(token: params["userToken"]).user
token = UserToken.new(user_id: user.id, token: access_token, token_type: "plaid_token")
token.save
end
下面的错误消息只是告诉我格式化令牌,就像它已经被格式化一样,所以我不确定还有什么问题。
错误信息:
Plaid::InvalidInputError (
Error Type : INVALID_INPUT
Error Code : INVALID_PUBLIC_TOKEN
Error Message : provided public token is in an invalid format. expected format: public-<environment>-<identifier>
Display Message :
Request ID : vaAqIgjQNZ2Zj07
):
在 public_key
中,您必须使用 Plaid 帐户中列出的密钥。 https://dashboard.plaid.com/account/keys
def set_plaid_token
public_token = params[:plaid_token]
client = Plaid::Client.new(env: :sandbox,
client_id: ENV['plaid_client_id'],
secret: ENV['plaid_secret'],
public_key: ENV['plaid_public_key'])
exchange_token_response = client.item.public_token.exchange(public_token)
access_token = exchange_token_response.access_token
...
end
Link:
let linkHandler = Plaid.create({
clientName: 'Name',
env: 'sandbox',
key: 'your-public-key-from-dashboard',
product: ['auth'],
onSuccess: function(public_token, metadata) {
$.post('/plaid/set_plaid_token', {
plaid_token: public_token
});
console.log('Pub tok = ' + public_token);
console.log('Account = ' + metadata.account_id);
}
});
document.getElementById('linkButton').onclick = function() {
linkHandler.open();
};
我在 React 中使用 Link 将 link 传递给 Items,然后将 public_token 传递到我的 rails 服务器,我试图在其中交换 public 访问令牌的令牌。 Link 成功将 public 令牌返回给我,它看起来像 public-sandbox-6df92f82-3260-4cb4-8489-65e6ac955e7a
我正在将其传递到我的 rails 服务器,我在服务器上使用格子-ruby gem 尝试交换代币。但是,我收到 INVALID_INPUT
错误。
格子-ruby码(params["plaidToken"] == public-sandbox-6df92f82-3260-4cb4-8489-65e6ac955e7a
):
def set_plaid_token
client = Plaid::Client.new(env: :sandbox,
client_id: '*******',
secret: '*******',
public_key: params["plaidToken"])
exchange_token_response = client.item.public_token.exchange('[Plaid Link public_token]')
access_token = exchange_token_response.access_token
#TODO users can add same bank twice.
user = UserToken.find_by(token: params["userToken"]).user
token = UserToken.new(user_id: user.id, token: access_token, token_type: "plaid_token")
token.save
end
下面的错误消息只是告诉我格式化令牌,就像它已经被格式化一样,所以我不确定还有什么问题。
错误信息:
Plaid::InvalidInputError (
Error Type : INVALID_INPUT
Error Code : INVALID_PUBLIC_TOKEN
Error Message : provided public token is in an invalid format. expected format: public-<environment>-<identifier>
Display Message :
Request ID : vaAqIgjQNZ2Zj07
):
在 public_key
中,您必须使用 Plaid 帐户中列出的密钥。 https://dashboard.plaid.com/account/keys
def set_plaid_token
public_token = params[:plaid_token]
client = Plaid::Client.new(env: :sandbox,
client_id: ENV['plaid_client_id'],
secret: ENV['plaid_secret'],
public_key: ENV['plaid_public_key'])
exchange_token_response = client.item.public_token.exchange(public_token)
access_token = exchange_token_response.access_token
...
end
Link:
let linkHandler = Plaid.create({
clientName: 'Name',
env: 'sandbox',
key: 'your-public-key-from-dashboard',
product: ['auth'],
onSuccess: function(public_token, metadata) {
$.post('/plaid/set_plaid_token', {
plaid_token: public_token
});
console.log('Pub tok = ' + public_token);
console.log('Account = ' + metadata.account_id);
}
});
document.getElementById('linkButton').onclick = function() {
linkHandler.open();
};