gottfrois / grape-knock Goto Github PK
View Code? Open in Web Editor NEWUse Knock with Grape.
License: MIT License
Use Knock with Grape.
License: MIT License
I got this error when running an RSpec test:
NameError:
uninitialized constant JWT
# ./spec/api/students_spec.rb:5:in `block (2 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# Grape::Knock::ForbiddenError:
# Grape::Knock::ForbiddenError
To fix, I had to require 'jwt'
at the top of my grape API class. Is that expected? It's not mentioned in the README.
The gem code in Rubygems is outdated. The last version is from August 20, 2015:
https://rubygems.org/gems/grape-knock/versions/0.1.1
Because of this, the current_user error is still happening:
NoMethodError (undefined method `current_user' for #Knock::AuthToken:0x00000003977a40):
I am not sure if it's the problem from Grape::Knock::Authenticable
, my front-end is a Vue project running on port 8080, and grape is on 3000. once I add use Grape::Knock::Authenticable
in grape api, the browser print following error:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 403.
I tried to add header manual but seems no effect
module Depot
class API < Grape::API
version 'v1', using: :path
format :json
prefix :api
before do
header "Access-Control-Allow-Origin", "*"
header "Access-Control-Allow-Headers", "Authorization, Content-Type"
header "Access-Control-Allow-Methods", "GET, PUT, POST, DELETE, OPTIONS"
end
Any idea?
Affected version: 0.1.1
Within the authenticate
method in Authenticable
.
https://github.com/gottfrois/grape-knock/blob/master/lib/grape/knock/authenticable.rb#L25
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.