{"id":13801120,"url":"https://github.com/kivra/oauth2_client","last_synced_at":"2026-02-21T17:33:43.498Z","repository":{"id":4295836,"uuid":"5426708","full_name":"kivra/oauth2_client","owner":"kivra","description":"Erlang OAuth2 Client","archived":false,"fork":false,"pushed_at":"2025-11-07T15:27:09.000Z","size":194,"stargazers_count":73,"open_issues_count":6,"forks_count":39,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-11-07T17:26:12.162Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Erlang","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/kivra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2012-08-15T14:03:17.000Z","updated_at":"2025-10-16T07:35:09.000Z","dependencies_parsed_at":"2025-05-13T11:43:25.524Z","dependency_job_id":null,"html_url":"https://github.com/kivra/oauth2_client","commit_stats":{"total_commits":54,"total_committers":17,"mean_commits":3.176470588235294,"dds":0.6666666666666667,"last_synced_commit":"47ba50a57e981253246b732cf31fb4df83fa260f"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/kivra/oauth2_client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kivra%2Foauth2_client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kivra%2Foauth2_client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kivra%2Foauth2_client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kivra%2Foauth2_client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kivra","download_url":"https://codeload.github.com/kivra/oauth2_client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kivra%2Foauth2_client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29688266,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T15:51:39.154Z","status":"ssl_error","status_checked_at":"2026-02-21T15:49:03.425Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-04T00:01:19.732Z","updated_at":"2026-02-21T17:33:38.486Z","avatar_url":"https://github.com/kivra.png","language":"Erlang","funding_links":[],"categories":["Third Party APIs"],"sub_categories":[],"readme":"# Oauth2 Client\nThis library is designed to simplify consuming Oauth2 enabled REST Services. It wraps a restclient and takes care of reauthenticating expired access_tokens when needed.\n\n## Flows\n\nImplemented flows are:\n\n- Client Credentials Grant\n- Resource Owner Password Credentials Grant\n\n## Example\n\nRetrieve a client with access_token using Password Credentials Grant\n\n```erlang\n1\u003e oauth2c:retrieve_access_token(\u003c\u003c\"password\"\u003e\u003e, \u003c\u003c\"Url\"\u003e\u003e, \u003c\u003c\"Uid\"\u003e\u003e, \u003c\u003c\"Pwd\"\u003e\u003e).\n{ok, Headers, Client}\n```\n\nRetrieve a client with access_token using Client Credentials Grant\n\n```erlang\n2\u003e oauth2c:retrieve_access_token(\u003c\u003c\"client_credentials\"\u003e\u003e, \u003c\u003c\"Url\"\u003e\u003e, \u003c\u003c\"Client\"\u003e\u003e, \u003c\u003c\"Secret\"\u003e\u003e).\n{ok, Headers, Client}\n```\n\n**Microsoft Azure AD**: Since parameters are different please use `\u003c\u003c\"azure_client_credentials\"\u003e\u003e` as `Type` when retrieving an access token for that service. Be sure to set a `Scope` if you want to access any of the connected APIs.\n\n```erlang\n2\u003e oauth2c:retrieve_access_token(\n    \u003c\u003c\"azure_client_credentials\"\u003e\u003e,\n    \u003c\u003c\"some_tenant_specific_oauth_token_endpoint\"\u003e\u003e,\n    \u003c\u003c\"some_registered_app_id\"\u003e\u003e,\n    \u003c\u003c\"some_created_key\"\u003e\u003e,\n    \u003c\u003c\"https://graph.microsoft.com\"\u003e\u003e).\n{ok, Headers, Client}\n```\n\nThe Opaque `Client` object is to be used on subsequent requests like:\n\n```erlang\n3\u003e oauth2c:request(get, json, \u003c\u003c\"Url\"\u003e\u003e, [200], Client).\n{{ok, Status, Headers, Body} Client2}\n```\n\nSee [restclient](https://github.com/kivra/restclient) for more info on how requests work.\n\n## Twitter Example\n\n```erlang\n-module(oauth2c_twitter_example).\n\n-export([ run/0\n        ]).\n\n-define(CONSUMER_SECRET, \u003c\u003c\"my_consumer_secret\"\u003e\u003e).\n-define(CONSUMER_KEY, \u003c\u003c\"my_consumer_key\"\u003e\u003e).\n\n-define(OAUTH2_TOKEN_URL, \u003c\u003c\"https://api.twitter.com/oauth2/token\"\u003e\u003e).\n\n-define(USER_TIMELINE_URL(User, StrCount),\n        \u003c\u003c\"https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=\"\n          , User, \"\u0026count=\", StrCount\u003e\u003e).\n\n-define(APP_LIMITS_URL(Resources),\n        \u003c\u003c \"https://api.twitter.com/1.1/application/rate_limit_status.json?resources=\"\n           , Resources\u003e\u003e).\nrun() -\u003e\n    application:ensure_all_started(oauth2c),\n    application:ensure_all_started(ssl),\n    {ok, _Headers, Client} =\n        oauth2c:retrieve_access_token(\n          \u003c\u003c\"client_credentials\"\u003e\u003e, ?OAUTH2_TOKEN_URL, ?CONSUMER_KEY,\n          ?CONSUMER_SECRET),\n    {{ok, _Status1, _Headers1, Tweets}, Client2} =\n        oauth2c:request(\n          get, json, ?USER_TIMELINE_URL(\"twitterapi\", \"4\"), [200], Client),\n    io:format(\"Tweets: ~p~n\", [Tweets]),\n    {{ok, _Status2, _Headers2, Limits}, _Client3} =\n        oauth2c:request(\n          get, json, ?APP_LIMITS_URL(\"help,users,search,statuses\"),\n          [200], Client2),\n    io:format(\"Limits: ~p~n\", [Limits]),\n    ok.\n```\n\n## License\nThe KIVRA oauth2 library uses an [MIT license](http://en.wikipedia.org/wiki/MIT_License). So go ahead and do what\nyou want!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkivra%2Foauth2_client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkivra%2Foauth2_client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkivra%2Foauth2_client/lists"}