{"id":13878415,"url":"https://github.com/mrkamel/oauth2_api_client","last_synced_at":"2025-07-05T20:35:04.840Z","repository":{"id":44938055,"uuid":"273590590","full_name":"mrkamel/oauth2_api_client","owner":"mrkamel","description":"Small but powerful client around oauth2 and http-rb to interact with APIs","archived":false,"fork":false,"pushed_at":"2024-02-19T12:09:18.000Z","size":51,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-23T23:05:24.310Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrkamel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-19T21:33:46.000Z","updated_at":"2022-08-22T15:26:48.000Z","dependencies_parsed_at":"2024-01-04T13:46:05.966Z","dependency_job_id":"3d42e994-645a-448c-af0b-277042966f1c","html_url":"https://github.com/mrkamel/oauth2_api_client","commit_stats":{"total_commits":24,"total_committers":2,"mean_commits":12.0,"dds":0.04166666666666663,"last_synced_commit":"8b2eb6bd008cd49648fc3f05b555b75a41783ec8"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrkamel%2Foauth2_api_client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrkamel%2Foauth2_api_client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrkamel%2Foauth2_api_client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrkamel%2Foauth2_api_client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrkamel","download_url":"https://codeload.github.com/mrkamel/oauth2_api_client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250528732,"owners_count":21445516,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T08:01:48.960Z","updated_at":"2025-04-23T23:05:32.519Z","avatar_url":"https://github.com/mrkamel.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# oauth2_api_client\n\n[![Build](https://github.com/mrkamel/oauth2_api_client/workflows/test/badge.svg)](https://github.com/mrkamel/oauth2_api_client/actions?query=workflow%3Atest+branch%3Amaster)\n[![Gem Version](https://badge.fury.io/rb/oauth2_api_client.svg)](http://badge.fury.io/rb/oauth2_api_client)\n\nOauth2ApiClient is a small, but powerful client around\n[oauth2](https://github.com/oauth-xx/oauth2) and\n[http-rb](https://github.com/httprb/http) to interact with APIs which use\noauth2 for authentication.\n\n```ruby\nclient = Oauth2ApiClient.new(base_url: \"https://api.example.com\", token \"oauth2 token\")\n\nclient.post(\"/orders\", json: { address: \"...\" }).status.success?\nclient.headers(\"User-Agent\" =\u003e \"API Client\").timeout(read: 5, write: 5).get(\"/orders\").parse(:json)\n# ...\n```\n\nIn case an API is unprotected and you still want to use Oauth2ApiClient, you\ncan simply not pass any token:\n\n```ruby\nclient = Oauth2ApiClient.new(base_url: \"...\")\n```\n\nOauth2ApiClient is capable of generating oauth2 tokens, when a client id,\nclient secret and oauth token url is given with automatic token caching and\nrenewal on expiry, including retry of the current request.\n\n```ruby\nclient = Oauth2ApiClient.new(\n  base_url: \"https://api.example.com\",\n  token: Oauth2ApiClient::TokenProvider.new(\n    client_id: \"client id\",\n    client_secret: \"client secret\",\n    token_url: \"https.//auth.example.com/oauth2/token\",\n    cache: Rails.cache, # optional,\n    max_token_ttl: 1800 # optional\n  )\n)\n```\n\nPlease note, `get`, `post`, `put`, etc. will raise\n`Oauth2ApiClient::ResponseError` unless the response code is 2xx. More\nspecifically, it will e.g. raise `Oauth2ApiClient::ResponseError::NotFound` for\na 404 status code, `Oauth2ApiClient::ResponseError::InternalServerError` for a\n500 status code, etc.\n\n## Default query params\n\nIn addition to the DSL of http-rb Oauth2ApiClient allows to set default query\nparams, which can be useful for some APIs:\n\n```ruby\nclient = Oauth2ApiClient.new(base_url: \"https://api.example.com\").params(key1: \"value1\")\nclient.get(\"/path\", params: { key2: \"value\" })\n#=\u003e GET https://api.example.com/path?key1=value1\u0026key2=value2\n```\n\n## Install\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'oauth2_api_client'\n```\n\nand then execute\n\n```\n$ bundle\n```\n\nor install it via\n\n```\n$ gem install oauth2_api_client\n```\n\n## Reference Docs\n\nThe reference docs can be found at\n[http://www.rubydoc.info/github/mrkamel/oauth2_api_client](http://www.rubydoc.info/github/mrkamel/oauth2_api_client)\n\n## Semantic Versioning\n\nOauth2ApiClient is using Semantic Versioning: [SemVer](http://semver.org/)\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrkamel%2Foauth2_api_client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrkamel%2Foauth2_api_client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrkamel%2Foauth2_api_client/lists"}