Salesforce REST API create new access_token in every thread

时间:2016-08-31 18:07:02

标签: java salesforce

I have a Java client that connects to Salesforce to send data to Salesforce. I've recently found out that this client can be multithreaded. I'm using a simple username/password to get the access token.

    post = new PostMethod(environment);
    post.addParameter( "grant_type", "password" );
    post.addParameter( "username", username );
    post.addParameter( "password", password );
    post.addParameter( "client_id", clientId );
    post.addParameter( "client_secret", clientSecret );

    httpClient.executeMethod( post );

Is this going to be a problem if each thread gets its own token? Does the previous token expire if a new one is created? If so, what's the best way to handle the multiple connections?

1 个答案:

答案 0 :(得分:0)

我可以回答你的一些问题:

  1. 通常,Salesforce每个SF帐户提供一个令牌(因此,您应该拥有用户名,密码和令牌)。

  2. 当您生成新令牌时,旧令牌会过期。

  3. 对于多线程连接 - 我不确定,SF是否允许与一个用户名/传递对并行连接。