Tadej Bukovec Posted February 17, 2021 Posted February 17, 2021 Hey! I managed to set up the auth request via Postman and received access and refresh token. I stored the refresh token in our database and was able to make further api requests with php. For oauth params i was using grant_type 'refresh_token', and for data i provided something like this: $this->oauthParams = array( 'client_id' => '[my client id]', 'client_secret' => '[my client secret]', 'grant_type' => 'refresh_token', 'refresh_token' => $refreshToken, ); And this was working fine for about 3, 4 days. Then suddenly, without changing any of this code since the first setup (i checked git history and all), this stopped working. Every call for getting new tokens results in a "failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request" response. What could be the cause of this issue? Is there a better, more stabile way of getting the access to api? Thank you for your time :)
Steel, Mark Posted February 18, 2021 Posted February 18, 2021 Hi Tadej, thank you for your question. We're not aware of any issue obtaining access_tokens in exchange for refresh_tokens providing the refresh_tokens are updated every time you exchange and the initial auth has not been revoked. If you can provide us with the request id of the failed auth attempt we can take a look at the logs on our server. Kind regards Mark
Bob Posted March 27, 2021 Posted March 27, 2021 Did you resolve this issue? I have run into what I believe is the same problem. I get the initial Access Token and Refresh token no issues, however when I attempt to renew the Access Token via the Refresh Token I am also getting, "failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request"
Bob Posted March 27, 2021 Posted March 27, 2021 9 hours ago, Bob said: Did you resolve this issue? I have run into what I believe is the same problem. I get the initial Access Token and Refresh token no issues, however when I attempt to renew the Access Token via the Refresh Token I am also getting, "failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request" Resolved my issues. After many hours I finally realised this was an error on my behalf. The PHP ltrim function I was using to truncate the refresh_token from the initial callback response was dropping the first character off the refresh_token, in essence providing an invalid refresh_token. Not sure why it was doing this so used str_replace.and it's now working. #Old code $refreshToken = ltrim($refreshToken, "refresh_token:"); #New code $refreshToken = str_replace("refresh_token:", "",$refreshToken);
Administrators Ben Smith Posted March 29, 2021 Administrators Posted March 29, 2021 Thanks for posting this Bob, I'm others will have/will do this so it being here will help! Glad you have it resolved. Ben
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now