Giter Site home page Giter Site logo

Comments (4)

nbulaj avatar nbulaj commented on August 22, 2024

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.

hardikg23 avatar hardikg23 commented on August 22, 2024

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.

nbulaj avatar nbulaj commented on August 22, 2024

@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.

nbulaj avatar nbulaj commented on August 22, 2024

Any update here?

from grape_oauth2.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.