0

以下は、新しいアクセス トークンを取得するための Box Api チュートリアルに記載されている手順です。

カール https://www.box.com/api/oauth2/token

-d 'grant_type=refresh_token&refresh_token={有効な更新トークン}&client_id= {your_client_id}&client_secret={your_client_secret}'

-Xポスト

これは私のコードです

 NSString* refresh =[NSString stringWithFormat:@"{%@}",[[arrUseraccounts objectAtIndex:[BoxDownloadFileViewControlller getSharedInstance].index] objectForKey:@"refresh_token"]];

    NSString* clientId =[NSString stringWithFormat:@"{%@}",[BoxSDK sharedSDK].OAuth2Session.clientID];
    NSString* clientSecret =[NSString stringWithFormat:@"{%@}", [BoxSDK sharedSDK].OAuth2Session.clientSecret];

   // NSDictionary * dic = [NSDictionary dictionaryWithObject:refresh forKey:@"refresh_token"];

    ASIFormDataRequest *postParams = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"https://www.box.com/api/oauth2/token?"]];
    //
    //    ASIFormDataRequest *postParams = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://www.box.com/api/oauth2/token?grant_type=refresh_token&refresh_token=%@&client_id=%@&client_secret=%@",refresh,clientId,clientSecret]]];

        [postParams setRequestMethod:@"POST"];

    //[postParams setPostBody:data];
    [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);
    NSLog(@"response string is-----> %@",postParams.responseString);

次の問題が発生しています。

{"error":"invalid_client","error_description":"The client credentials are invalid"}

Box Api チュートリアル で指定されたパラメーターを渡す方法を提案してください。

4

1 に答える 1

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);
于 2014-08-16T12:58:51.497 に答える