Some time get error "Invalid grant_type parameter or parameter missing" on renew access token
AnsweredI am using refresh token to automate updating of access and refresh tokens. It works pretty well. However, sometimes the access token renewal fails and i receive the title error.
{"error":"invalid_request","error_description":"Invalid grant_type parameter or parameter missing"}
As far as I can tell, whenever there is a failure there is a 302 redirect and the destination is "https://app.box.com//api/oauth2/token".
As you know, if the refresh token update fails, you will not be able to get an access token without OAuth authentication again.
How do I solve this problem?
Thank you in advance.
-
Hello,
There was a regression in behavior when attempting to use the https://www.box.com/api/oauth2/token URL to obtain a token. Late last night, our engineering team pushed out a fix that restored functionality to this URL. This particular URL is a remnant of version 1 of Box's API. This v1 had an EOL announced back in October 1st of 2013 as seen here:
https://blog.box.com/start-migrating-to-v2-of-the-content-api-deprecating-v1-in-december
With this in mind, we request that you begin moving your application(s) toward using the formally supported endpoint in version 2 of our API which is https://api.box.com/oauth2/token as seen here:
https://developer.box.com/reference/post-oauth2-token/
Best,
Kourtney
Box Technical Support Engineer
-
Hi Courtney,
I've been using the api.box.com entry point for some time, but recently, have also started getting the "Invalid grant_type" error - this application runs in VBA (yes, it's pretty old..) in an Access database. It used to run fine, but now throws the "Invalid grant_type parameter or parameter missing" error. Nothing has changed in this code for a couple of years. The temp_code (from the user authentication who grants access) still works fine - the dialog comes up correctly, the "grant access to box" comes up correctly after password verification, and the returned temp code is captured. Then the code below is executed (client ID and secret not shown obviously, but they have not changed in years). Instead of getting a refresh code, it now trips on the error.
Any help would be appreciated.
targetURL = "https://api.box.com/oauth2/token"
paramstr = "grant_type=authorization_code" & _
"&code=" & Temp_Code & _
"&client_id=[clinet id]" & _
"&client_secret=[client secret]"
Set HTTPReq = CreateObject("MSXML2.XMLHTTP")
HTTPReq.Open "POST", targetURL, False
HTTPReq.SetRequestHeader "Content-Type", "application/json"
HTTPReq.SetRequestHeader "Accept", "application/json"
HTTPReq.Send paramstr
JSON_Response = HTTPReq.responseText
'get the refresh code and new authorization
fault_string = "error"
found_error = InStr(1, JSON_Response, fault_string)
If found_error > 0 Then
MsgBox "Could not authorize, please log in and grant access to enable cloud links" -
Hi Team,
We are facing Same issue like "Invalid grant_type parameter or parameter missing" . We are using latest version 2 but its getting error and unable to access the box.com.
Code:
String urlParameters = 'grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer'
+ '&client_id='+ClientId+'&client_secret='+ClientSecret+'&assertion='+jwtAssertion;
HttpRequest request = new HttpRequest();
request.setMethod('POST');
request.setEndpoint('https://api.box.com/oauth2/token');
request.setBody(urlParameters);
request.setHeader('content-type','application/json');
Http h = new Http();
HttpResponse response = h.send(request);We got the below response from above request. Please let me know where we have done wrong.
Error:
{"error":"invalid_request","error_description":"Invalid grant_type parameter or parameter missing"}
Thank You,
Mahesh
Please sign in to leave a comment.
Comments
9 comments