Skip to content

carabao-capital/http-auth0

Repository files navigation

http-auth0

CI

HTTP client abstraction layer for Auth Application RFC

Installation

Add these lines to your application's Gemfile:

source 'https://rubygems.pkg.github.com/carabao-capital' do
  gem 'http-auth0'
end

And then execute:

$ bundle

Usage

Configure the gem in an initializer

HTTP::Auth0.configure do |auth0|
  auth0.domain = 'insert-domain-here.jp.auth0.com'
  auth0.client_id = 'insert-client-id-here'
  auth0.client_secret = 'insert-client-secret-here'
end

Use with your preferred HTTP client

Faraday Example

require 'faraday'
require 'faraday/net_http'
require 'http/auth0/middleware'

conn = Faraday.new do |f|
  f.use HTTP::Auth0::Middleware
end

conn.post("https://staging-01.api.connect.my.firstcircle.ph/graphql")

Net::HTTP Example

require 'http/auth0'
require 'net/http'    

uri = URI("https://staging-01.api.connect.my.firstcircle.ph/graphql")
req = Net::HTTP::Get.new(uri)
req['Authorization'] = HTTP::Auth0.token(aud: uri.to_s)

res = Net::HTTP.start(uri.hostname, uri.port) do |http|
  http.request(req)
end

puts res.body

Dependencies

Contributing

  1. Clone the http-auth0 repo
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

HTTP client abstraction layer for Auth Application RFC.

Resources

License

Stars

Watchers

Forks

Packages

No packages published