0
votes

I'm getting an error while getting new access token with Box.

https://www.box.com/api/oauth2/token?grant_type=ItJDebeTnnPuW6ml6eHDRRSuQXHJx1EmNxcrfFPfdlt4Gd2GhcnMhPfYynnzqwdK&refresh_token=ItJDebeTnnPuW6ml6eHDRRSuQXHJx1EmNxcrfFPfdlt4Gd2GhcnMhPfYynnzqwdK&client_id=14yzd7a5wb17xmsdc0ti2resb5e1pvbr&client_secret=RHRjNZV04vj5w0ca8BskgEkuFNrTd1Lu

{"error":"invalid_request","error_description":"Invalid grant_type parameter or parameter missing"}

Here is the documentation to get new box access token .

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

I'm passing grant_type and refresh_token as same refresh token . If both are different then what i need to pass values for grant_type and refresh_token .

1

1 Answers

0
votes

I got the solution ,

 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);