【问题标题】:Invalid grant_type parameter or parameter missing while getting new access token to handle expired Access token获取新的访问令牌以处理过期的访问令牌时,grant_type 参数无效或参数丢失
【发布时间】:2014-10-06 23:00:36
【问题描述】:

我在使用 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"}

这是获取新盒子访问令牌的文档。

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_typerefresh_token 作为相同的刷新令牌传递。如果两者都不同,那么我需要传递 grant_type 和 refresh_token 的值。

【问题讨论】:

    标签: ios api box


    【解决方案1】:

    我得到了解决方案,

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-19
      • 1970-01-01
      • 1970-01-01
      • 2018-02-17
      • 2020-12-18
      • 1970-01-01
      • 2018-07-23
      • 1970-01-01
      相关资源
      最近更新 更多