Ios 使用zkSForce访问salesforce沙盒
我在iOS应用程序中使用了zkSForce登录SalesForce。现在,我需要为同一个应用程序访问沙箱环境中的相同数据 但是当我尝试登录时,我得到了以下错误 错误域=APIRROR Code=0“操作无法完成。(APIRROR错误0。)”用户信息=0xad3ef20Ios 使用zkSForce访问salesforce沙盒,ios,salesforce,sandbox,Ios,Salesforce,Sandbox,我在iOS应用程序中使用了zkSForce登录SalesForce。现在,我需要为同一个应用程序访问沙箱环境中的相同数据 但是当我尝试登录时,我得到了以下错误 错误域=APIRROR Code=0“操作无法完成。(APIRROR错误0。)”用户信息=0xad3ef20 {faultstring=INVALID_LOGIN: Invalid username, password, security token; or user locked out., faultcode=INVALID_LOGI
{faultstring=INVALID_LOGIN: Invalid username, password, security token; or user locked out., faultcode=INVALID_LOGIN}
但当我尝试连接到生产环境时,我能够成功登录。使用zkSForce连接到沙盒时,是否需要遵循任何特定的说明?提前谢谢
--编辑--
我正在使用以下方法登录
[SFAccountManager setLoginHost:@"test.salesforce.com"];
[SFAccountManager setClientId:CLIENTID];
[SFAccountManager setRedirectUri:REDIRECTURI];
[SFAccountManager setCurrentAccountIdentifier:USERNAME];
[SFAccountManager sharedInstance].coordinator.credentials.instanceUrl=[NSURL URLWithString:@"https://test.salesfoce.com"];
[[FDCServerSwitchboard switchboard] loginWithUsername:username password:passwordToken target:self selector:@selector(loginResult:error:)];
并通过以下方法处理结果
- (void)loginResult:(ZKLoginResult *)result error:(NSError *)error{
if (result && !error){
[[SFAccountManager sharedInstance].coordinator.credentials setAccessToken:nil];
[SFAccountManager sharedInstance].coordinator.credentials.accessToken = result.sessionId;
}
else if (error){
UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Login failed" message:@"Error" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[myAlertView show];
}
}
沙盒的登录请求需要转到与生产环境默认端点不同的端点,因此您需要在调用Login之前在客户端对象上调用setLoginProtocolAndHost:,例如
ZKSforceClient *c = [[ZKSforceClient alloc] init];
[c setLoginProtocolAndHost:@"https://test.salesforce.com"];
[c login:self.username password:self.password];
...
我不确定这是否是一个完美的解决方案,但添加以下行对我很有效
[[FDCServerSwitchboard switchboard] setApiUrlFromOAuthInstanceUrl:LOGINHOSTURL];
其中LOGINHOSTURL是您的主机URL
感谢@superfell给我提示我已将登录主机设置为适当的主机,即test.salesforce.com本身。但它仍然不起作用我不知道你在使用什么工具,但ZKSforce中没有SFAccountManager类。看见