Intermittent "invalid_request" when requesting token

SOLVED
Go to solution
Highlighted
New Contributor

Intermittent "invalid_request" when requesting token

About ever other time I attempt to retrieve a token from https://www.box.com/api/oauth2/token, I receive this error:

 

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

 

If I execute the exact same request again I get the correct response. Example without token:

 

{"access_token":"xyz","expires_in":4206,"restricted_to":[],"token_type":"bearer"}

 

 I can provide our client ID or enterprise ID if that's helpful for looking at logs.

 

Thanks for any help.

 

Tags (3)
10 REPLIES 10
Highlighted
Box Employee

Re: Intermittent "invalid_request" when requesting token

Hi there,

 

It looks like the issue is that the correct endpoint to use for a token request is https://api.box.com/oauth2/token instead of https://www.box.com/api/oauth2/token as listed in the documentation here. Please try using this new endpoint to see if this resolves the issue, and if not, please feel free to submit a support ticket so that we can investigate this further.

 

Thank you for using the Box Community!

Highlighted
New Contributor

Re: Intermittent "invalid_request" when requesting token

Thanks @zkimmell, I swapped out the URLs and made about 20 requests and that seems to work.

 

Do you have any idea why the other URL would work about 1/2 the time? And seemed to work all the time up until a couple weeks ago? Was https://www.box.com/api/oauth2/token recently deprecated?

 

Thanks again for the solution.

 

Matt

Highlighted
First-time Contributor

Re: Intermittent "invalid_request" when requesting token

That did the trick for me also!

The random nature of this was very confusing , why not returning a HTTP 3xx (or even a HTTP 404) when calling the old endpoint?

Highlighted
Community Manager

Re: Intermittent "invalid_request" when requesting token

We’ve asked our Engineering team to investigate this issue. Meanwhile, the solution provided here will work and is aligned with our public documentation on our OAuth2 endpoint at https://developer.box.com

Highlighted
New Contributor

Re: Intermittent "invalid_request" when requesting token

Hi, I'm using the new URL but still getting the "Invalid grant_type parameter or parameter missing" error. It was working up until last week. Could there be something else causing the issue? 

Highlighted
Occasional Contributor

Re: Intermittent "invalid_request" when requesting token

I also am using the "new" URL - have in fact been using it for ages, and am just now getting errors.

Is there any way to get an authorization token at all at the moment? I seem to be unable to do so, not just intermittently but permanently, which leaves my app "dead in the water".

Looks like i'm not the only one.

 

Box folks, could you please look into this as something that is buggy with the new URL (https://api.box.com/oauth2/token) rather than calling the issue solved? 

My code was also working until recently and did not change.

 

thanks,

Highlighted
First-time Contributor

Re: Intermittent "invalid_request" when requesting token

This is causing an issue for me also. Request seems to work through Postman but doesn't when using VB.net?

Highlighted
First-time Contributor

Re: Intermittent "invalid_request" when requesting token

Having same issue here with 3rd party integration with Box api.. It's been working for a while, but broke recently. Any help would be much appreciated.

Highlighted
Occasional Contributor

Re: Intermittent "invalid_request" when requesting token

This is an issue for me as well. Was working fine until recently and now will not work at all, which is causing major problems for our company. We didn't make any changes on our end so the problem must be on Box's end. Box, please look into this ASAP!

Highlighted
Occasional Contributor

Re: Intermittent "invalid_request" when requesting token

All - Per Box support, this issue was caused by a change on their end. When requesting the access the token, the header's content type must be set like 

    var headers = {
        'Content-Type': 'application/x-www-form-urlencoded'
    };
Hopefully this fixes things for a few of you!