Comments (13)
I know this is an old thread, but I ran into this same problem just now and thought it'd be useful to warn other people to double check a missing http://
in the beginning of the url.
That solved it for me. 😉
from her.
I guess the problem is here:
connection.use Faraday::BasicAuthentication.basic_auth("user","pass")
Can you try using it like this?
# config/initializers/her.rb
Her::API.setup :url => "http://127.0.0.1:3003/api/v1/" do |connection|
connection.use Faraday::Request::BasicAuthentication "user", "pass"
connection.use Faraday::Request::UrlEncoded
connection.use Her::Middleware::DefaultParseJSON
connection.use Faraday::Adapter::NetHttp
end
from her.
No, that wasn't the problem. I even tried it out without any authentication in there hoping to run in a 403.
from her.
@ceicke I have not been able to reproduce the error… Did you find a fix for it or are you still experiencing the issue?
from her.
I wasn't able to resolve the problem and have therefore moved on to implementing the REST interface that I connect to with pure HTTP calls. I think you can close this issue and wait if it comes up again. I was implementing "her" in a really complicated project, so maybe there were some side effects from other Gems etc.
from her.
I have the same issue, and I know why.
class A::B::C
include Her::Model
end
C.find(1) produces path like "a::b::c/1"
from her.
@teamon Do you know why?
If I run the following code:
def stub_api_for(klass)
klass.uses_api (api = Her::API.new)
# Here, you would customize this for your own API (URL, middleware, etc)
# like you have done in your application’s initializer
api.setup :url => "https://api.example.com" do |connection|
connection.use Her::Middleware::DefaultParseJSON
connection.adapter(:test) { |s| yield(s) }
end
end
module A
module B
end
end
class A::B::C
include Her::Model
end
stub_api_for(A::B::C) do |stub|
stub.get("/cs/1") do |env|
[200, {}, { :id => 1, :foo => "bar"}.to_json]
end
end
p A::B::C.find(1)
I get this output:
#<A::B::C(cs/1) id=1 foo="bar">
from her.
I was referencing older version of her (0.2.x), 0.4.1 resolved that issue (not sure if exactly 0.4.1, but 0.4.1 works for me)
from her.
I got the same error but eventually got it working. It turned out that I was missing a "http://" in Her::API.setup(url: "http://mysite.com/api")
from her.
I received the same error and determine from the source I needed to call the header method to set user, pass.
c.use Faraday::Request::BasicAuthentication.header user, password
from her.
I am not able to get basic authentication working,. Here's what I have tried:
Her::API.setup :url => "https://my.favourite_api.org" do |connection|
Authentication
connection.use Faraday::Request::BasicAuthentication "itsme", "letmein"
The RubyMine debugger tells me:
Uncaught exception: undefined method `BasicAuthentication' for Faraday::Request:Class
Can anyone help?
from her.
It was simply a missing comma:
connection.use Faraday::Request::BasicAuthentication, "itsme", "letmein"
from her.
@nickweavers comment works for me. I added a PR to the readme.
from her.
Related Issues (20)
- path_prefix option is not used when belongs_to association is set. HOT 5
- add ability to wrap "where" clause HOT 4
- Support for first, limit, group and order HOT 6
- Support for update_attributes missing? HOT 6
- Support for association extensions HOT 1
- undefined method `map' for nil:NilClass for association HOT 6
- Class-level response parsing? HOT 1
- Scopes on JsonApi model
- Find or Create by ID HOT 2
- Have we considered making this gem more SEO friendly? HOT 4
- Attributes don't play nicely with ActiveModel::Dirty in Rails 6
- Safe Navigation Operator &. don't works on nil objects
- I would like to have find_by! in order to raise an exception instead of a nil HOT 1
- HashWithIndifferentUsage is slow, and requires large ActiveSupport dependency
- ruby 2.7, rails 6.0 and faraday 1.0 HOT 3
- Release version 1.1.1 HOT 1
- her-rb.org website inaccessible. HOT 1
- Organizing a fork of her HOT 1
- Execute rescue_from plus her? HOT 1
- Model.all returns empty array, but response has data HOT 1
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 her.