Skip to content

HTTP client abstraction layer for Auth0 protected endpoint.

License

Notifications You must be signed in to change notification settings

itsmechlark/http-auth0

This branch is 24 commits ahead of carabao-capital/http-auth0:main.

Folders and files

NameName
Last commit message
Last commit date
Sep 15, 2023
Sep 15, 2023
Jan 31, 2022
Sep 10, 2023
Sep 10, 2023
Mar 16, 2022
Sep 10, 2023
Mar 16, 2022
Sep 10, 2023
Sep 10, 2023
Sep 10, 2023
Sep 15, 2023
Sep 10, 2023
Sep 10, 2023
Jan 31, 2022
Mar 16, 2022
Sep 10, 2023
Sep 15, 2023

Repository files navigation

http-auth0

CI Gem Version Coverage Status Maintainability

HTTP client abstraction layer for Auth Application RFC

Installation

Add these lines to your application's Gemfile:

source 'https://rubygems.pkg.github.com/itsmechlark' 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://example.com/graphql")

Net::HTTP Example

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

uri = URI("https://example.com/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 Auth0 protected endpoint.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 97.3%
  • Shell 2.7%