Comments (4)
Hi @hardikg23 . Once again, what is your purpose? You need to pass invalid tokens or what?
Helper access_token_required!
already checks access token for validness (token can't be revoked or expired and must match scopes).
from grape_oauth2.
Hi, @nbulaj In my case access token is optional in header for GET request so I can not use helper access_token_required!
. But in case if access token is present is should be valid not expired one. Access Token in request is just to identify current user for analytics purpose, client may choose to not to pass in header in that case its absolutely fine.
from grape_oauth2.
@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
current_access_token
helper exists only for getting an instance of Access Token, not to check it validness
from grape_oauth2.
Any update here?
from grape_oauth2.
Related Issues (6)
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 grape_oauth2.