-
Notifications
You must be signed in to change notification settings - Fork 6
Refactor oauth #317
base: develop
Are you sure you want to change the base?
Refactor oauth #317
Conversation
spec/factories_spec.rb
Outdated
mock.post "/users.json", {"Content-Type"=>"application/json", "authorization"=>"Bearer "}, @smurf.to_json, 201, "Location" => "/users/smurf.json" | ||
mock.get "/users/smurf.json", {"Accept"=>"application/json", "authorization"=>"Bearer "}, @smurf.to_json | ||
mock.post "/users.json", {"Content-Type" => "application/json", authorization: "Bearer "}, @smurf.to_json, 201, "Location" => "/users/smurf.json" | ||
mock.get "/users/smurf.json", {"Accept" => "application/json", authorization: "Bearer "}, @smurf.to_json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to use strings here? can't we use symbols?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, but the dash in "Content-Type" still needs the quotes. It would look something like this:
{"Content-Type": "application/json", authorization: "Bearer "}
We can do that or change back to using strings as keys. I'm not sure which option is the best, but I can agree that the mixing of styles should be avoided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@malmers But it does look like that? I agree that we shouldn't mix the styles - so make "Authorization" a string too! 😄
0b9f169
to
7a30a49
Compare
Looks fine, but maybe we should look into not creating a new token every time? |
Yes, we should probably upgrade doorkeeper at chalmersit-account-rails before this is merged. I'm also not that happy with the extra startup time this PR introduces, maybe we should only use automatic token fetching as a fallback if there isn't one provided. |
Sounds like a good idea! |
Use omniauth to fetch data using the oauth 2 client credentials flow. Also request the access token on startup to simplify installation.