我在使用Box获取新的访问令牌时遇到错误。
{"error":"invalid_request","error_description":"Invalid grant_type parameter or parameter missing"}
以下是获取新盒子访问令牌的文档。
curl https://www.box.com/api/oauth2/token -d 'grant_type=refresh_token&refresh_token={valid refresh token}&client_id={your_client_id}&client_secret={your_client_secret}' -X POST
我将grant_type
和refresh_token
作为相同的刷新令牌传递。如果两者都不同,那么我需要传递grant_type和refresh_token的值。
答案 0 :(得分:0)
我得到了解决方案,
NSString* refresh =your refresh token;
NSString* clientId =[NSString stringWithFormat:@"%@",[BoxSDK sharedSDK].OAuth2Session.clientID];
NSString* clientSecret =[NSString stringWithFormat:@"%@", [BoxSDK sharedSDK].OAuth2Session.clientSecret];
ASIFormDataRequest *postParams = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"https://www.box.com/api/oauth2/token?"]];
[postParams setRequestMethod:@"POST"];
[postParams setPostValue:@"refresh_token" forKey:@"grant_type"];
[postParams setPostValue:refresh forKey:@"refresh_token"];
[postParams setPostValue:clientId forKey:@"client_id"];
[postParams setPostValue:clientSecret forKey:@"client_secret"];
[postParams startAsynchronous];
postParams.delegate = self ;
postParams.userInfo = [NSDictionary dictionaryWithObject:@"accessToken" forKey:@"id"];
NSLog(@"Url is ---> %@",postParams.url);