Skip to content
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

signet as Faraday middleware? #7

Open
sporkmonger opened this issue Dec 17, 2012 · 1 comment
Open

signet as Faraday middleware? #7

sporkmonger opened this issue Dec 17, 2012 · 1 comment
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@sporkmonger
Copy link
Contributor

With the switch to Faraday, it might make sense to offer signet as Faraday middleware rather than acting as a front-end to it. E.g.

client = Signet::OAuth2::Client.new...
access_token = ... # get access token

conn = Faraday.new do |builder|
  builder. user Signet::OAuth2::Client, access_token
end

conn.get(...)

(Copied from @sqrrrl's issue on the original Signet project.)

@JustinBeckwith JustinBeckwith added triage me I really want to be triaged. 🚨 This issue needs some love. and removed 🚨 labels Jul 30, 2018
@TheRoyalTnetennba TheRoyalTnetennba added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Jul 30, 2018
@bouk
Copy link

bouk commented Mar 23, 2021

I created a middleware that'll do this for you

class CredentialsMiddleware < Faraday::Middleware
  def on_request(env)
    options[:client].apply! env.request_headers
  end
end

credentials = Google::Auth::Credentials.default
conn = Faraday.new(url: "...") do |c|
  c.use CredentialsMiddleware, client: credentials.client
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

4 participants