Refactor to a Service Oauth file:
response = Faraday.post("https://github.com/login/oauth/access_token?client_id=#{ENV["github_client_id"]}&client_secret=#{ENV["github_client_secret"]}&code=#{params["code"]}") token = response.body.split(/\W+/)[1] oauth_response = Faraday.get("https://api.github.com/user?access_token=#{token}") auth = JSON.parse(oauth_response.body)
Refactor to a Service Oauth file:
response = Faraday.post("https://github.com/login/oauth/access_token?client_id=#{ENV["github_client_id"]}&client_secret=#{ENV["github_client_secret"]}&code=#{params["code"]}") token = response.body.split(/\W+/)[1] oauth_response = Faraday.get("https://api.github.com/user?access_token=#{token}") auth = JSON.parse(oauth_response.body)