简体   繁体   English

Salesforce REST API在每个线程中创建新的access_token

[英]Salesforce REST API create new access_token in every thread

I have a Java client that connects to Salesforce to send data to Salesforce. 我有一个Java客户端,该客户端连接到Salesforce以将数据发送到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? 如果是这样,处理多个连接的最佳方法是什么?

I can answer on some of your questions: 我可以回答您的一些问题:

  1. Usually Salesforce provides one token per one SF account (so, you should have username, password and token). 通常,Salesforce为每个SF帐户提供一个令牌(因此,您应该具有用户名,密码和令牌)。

  2. When you generate new token the old one expire. 当您生成新令牌时,旧令牌将过期。

  3. As for multithreading connection - I'm not sure, SF allows or not to connect in parallel with one username/pass pair. 至于多线程连接-我不确定,SF是否允许使用一个用户名/密码对并行连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM