Comments (3)
Yeah the problem would be that Box is returning a 400 error when it used to return a 401. I'm not sure what is causing that but that's the reason it's not refreshing. Are you ever able to get a 401? That's just odd that the error code would change. If we can confirm then I can easily update the gem but we should make sure we know why the change in error code first.
Chad
Sent from my iPhone
On Jun 14, 2016, at 10:33 AM, Jonathan Simmons [email protected] wrote:
Problem:
The boxr client is returning Boxr::BoxrError: 400: {"error":"invalid_client","error_description":"The client credentials are invalid"} with known good credentials.Stats:
Rails: 5.0.0.rc1
Ruby: 2.3.0Background:
I've got a rails app that is using the devise gem for omniauth support for authentication with the "omniauth-box-oauth2" for the box strategy.I'm able to authenticate a user, begin using their token with the boxr gem to manage the user resources on their behalf. That part all worked fine. Then after an undetermined period, maybe an hour, the token is invalidated. I was expecting the boxr gem, because I passed the refresh_token during initialization, to auto refresh the token for me.
Here is my client initialization code:
token_refresh_listener = lambda { |access, refresh, identifier|
User.find(identifier).update_columns(
token: access,
refresh_token: refresh
)
}client = Boxr::Client.new(
@user.access_token,
refresh_token: @user.refresh_token,
client_id: ENV["BOX_CLIENT_ID"],
client_secret: ENV["BOX_CLIENT_SECRET"],
identifier: @user.id,
&token_refresh_listener
)
This however is not happening. I was confused so I just tired to use a native rest client to make the refresh call for a new token. Sure enough, it worked fine. I got a response new access and refresh tokens.Still cautious I went to the database updated the corresponding user and tried to use boxr gem again. BOOM it magically started working. It was odd that the boxr gem didn't auto refresh but I though maybe I did something wrong?
Then an hour later it stopped again. After looking through the boxr code for a good bit I noticed that the refresh code here was looking for a 401 but the error I was getting was a 400 invalid_client. So it wasn't even getting a chance to try to refresh the token because it thinks the client is invalid
To make sure I wasn't crazy I tried to just use the boxr gem directly to refresh the token like so:
Boxr::refresh_tokens(User.first.refresh_token, client_id: ENV["BOX_CLIENT_ID"], client_secret: ENV["BOX_CLIENT_SECRET"])
This again returned:Boxr::BoxrError: 400: {"error":"invalid_client","error_description":"The client credentials are invalid"}
confirming my suspicion that something wasn't right. The credentials aren't invalid though. They are the same creds I've been using the this time, and if I make a curl request or use some external request app to refresh the token and those creds it all works fine.What am I missing?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
from boxr.
So after a good bit of digging It turns out this is my fault. In console testing I have set the ENV["BOX_CLIENT_ID"]
I created an box.rb
initializer to set those in the app but accidentally put it in directly in config folder instead of the initializers folder. #doh
Thanks for responding!
from boxr.
Ok cool. Thanks for the update!
Sent from my iPhone
On Jun 15, 2016, at 5:20 PM, Jonathan Simmons [email protected] wrote:
So after a good bit of digging It turns out this is my fault. In console testing I have set the ENV["BOX_CLIENT_ID"]
I created an box.rb initializer to set those in the app but accidentally put it in directly in config folder instead of the initializers folder. #doh
Thanks for responding!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
from boxr.
Related Issues (20)
- Box Header Changes - Deadline May 10, 2021 HOT 1
- Transferring files from S3 to Box in chunks without a tmp file HOT 1
- Add a guide for chunked IO transfer with a session
- Release a version that does not cause Hashie conflict messages HOT 2
- Support for Client Credentials Grant HOT 2
- all_users method not respecting "limit" or "filter_term" HOT 1
- *** Boxr::BoxrError Exception: 404: Not Found when create_folder with boxr gem HOT 3
- Bug when an upload session commits and Box returns a 202 HOT 7
- Boxr::Client.instance_methods doesn't contain create_zip_download HOT 1
- upload_file resulting in 'The specified Content-MD5 did not match what we received' error HOT 4
- Boxr::WebhookValidator fails to validate V2 webhook signatures HOT 2
- Need update addressable to version >= 2.8.0
- create_user check_response_status': 400: Bad Request (Boxr::BoxrError) HOT 2
- Cannot create shared_link with no expiration HOT 2
- Invalid Grant: exp claim exceeds the maximum value when getting tokens via JWT HOT 1
- 400 invalid_grant, Refresh token has expired HOT 3
- Upload a file from an IO object HOT 7
- I want user boxr with proxy server HOT 2
- Reliant on a 6-year old version of OJ
- Supporting case-insensitive for Box's API response headers HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from boxr.