-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expired access token not giving unauthorized Error #10
Comments
Hi @hardikg23 . Once again, what is your purpose? You need to pass invalid tokens or what? Helper |
Hi, @nbulaj In my case access token is optional in header for GET request so I can not use helper |
@hardikg23 maybe you need to implement some helper and use it in your endpoints? #app/some_helpers.rb
module SomeHelpers
extend ::Grape::API::Helpers
def check_access_token!
token = current_access_token
# any logic
if token.nil? || token.expired? || token.revoked?
raise Rack::OAuth2::Server::Resource::Bearer::Unauthorized
end
end
end
# app/endpoints/some.rb
get :endpoint do
check_access_token!
# do something
end
|
Any update here? |
In our application we allow client to pass access tokens(optional) for GET requests for analytics and reports. But if client pass very old access token which is expired in request gem does not Unauthorized the request. For which I am doing following change in the code.
Is this a valid change? or I am missing something?
The text was updated successfully, but these errors were encountered: