dbernheisel / req_github_oauth

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ReqGitHubOAuth

Req plugin for GitHub authentication.

The plugin authenticates requests to GitHub using GitHub OAuth Device Flow. The GitHub OAuth it uses is: https://github.com/apps/reqgithuboauth.

Usage

Mix.install([
  {:req, github: "wojtekmach/req"},
  {:req_github_oauth, github: "wojtekmach/req_github_oauth"}
])

req = Req.new(http_errors: :raise) |> ReqGitHubOAuth.attach()
Req.get!(req, url: "https://api.github.com/user").body["login"]
# Outputs:
# paste this user code:
#
#   6C44-30A8
#
# at:
#
#   https://github.com/login/device
#
# open browser window? [Yn]
# 15:22:28.350 [info] response: authorization_pending
# 15:22:33.519 [info] response: authorization_pending
# 15:22:38.678 [info] response: success
#=> "wojtekmach"

Req.get!(req, url: "https://api.github.com/user").body["login"]
#=> "wojtekmach"

About


Languages

Language:Elixir 100.0%