[英]OAuth Refresh Token Process for salesforce SDK
Can anyone help me with refreshing token on saleforce. 谁能帮助我刷新saleforce上的令牌。
NSDictionary *fields = @{@"grant_type" : @"refresh_token",
@"refresh_token": oauth[@"refreshToken"],
@"client_id": coordinator.credentials.clientId,
@"format": @"json"
};
SFRestRequest *request = [SFRestRequest requestWithMethod:SFRestMethodPOST path:[NSString stringWithFormat:@"%@/services/oauth2/token",[SFAccountManager loginHost]] queryParams:fields];
request.endpoint = [NSString stringWithFormat:@"%@/services/oauth2/authorize", [SFAccountManager loginHost]];
[[SFRestAPI sharedInstance] sendRESTRequest:request failBlock:^(NSError *e) {
NSLog(@"Error %@", e);
} completeBlock:^(NSDictionary* dict) {
NSLog(@"dict");
}];
This is what i am trying to do, but i am getting the following error: 这是我正在尝试执行的操作,但是出现以下错误:
Error Domain=NSURLErrorDomain Code=404 "The operation couldn't be completed. (NSURLErrorDomain error 404.)" UserInfo=0x7993c670 {Transfer-Encoding=Identity, Content-Type=text/html;charset=UTF-8, Date=Thu, 13 Nov 2014 15:23:36 GMT} 错误域= NSURLErrorDomain代码= 404“操作无法完成。(NSURLErrorDomain错误404。)” UserInfo = 0x7993c670 {Transfer-Encoding = Identity,Content-Type = text / html; charset = UTF-8,Date = Thu ,2014年11月13日15:23:36 GMT}
I am not sure what is going wrong. 我不确定出了什么问题。 FYI: Understanding the OAuth Refresh Token Process
仅供参考: 了解OAuth刷新令牌过程
This is the request: 这是请求:
endpoint: test.salesforce.com/services/oauth2/authorize
method: POST
path: test.salesforce.com/services/oauth2/token
queryParams: {"grant_type":"refresh_token","refresh_token":"5AsdfdfssdBuiV6yFNukUqDSMUH1tnk39L.x0GFcdqdMhpmQUTu.wv1BNndfglD3SxEZIFUev4i8T2KLkcCOK","format":"json","client_id":"3MVG9dPGzsddfssfdsOQG3p9KW.2hh3Bh5BeEsdfsRlDhxcybG.YRTQC0C0XayvzEw.5.umftLwJpYjYVDE6xgSCgXo"}
I stopped using Salesforce and NSURL Kit instead i use AFHTTPREQUEST 我停止使用Salesforce和NSURL Kit,而是使用AFHTTPREQUEST
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
[dict setObject:@"password" forKey:@"grant_type"];
[dict setObject:@"xxx" forKey:@"client_id"];
[dict setObject:@"xxx" forKey:@"client_secret"];
[dict setObject:@"your user" forKey:@"username"];
[dict setObject:@"password" forKey:@"password"];
[dict setObject:@"json" forKey:@"format"];
[manager POST:@"https://test.salesforce.com/services/oauth2/token" parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject)
{
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
}];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.