LoginSignup
0
0

More than 1 year has passed since last update.

RubyのGETリクエストを送る際にヘッダを指定する方法

Posted at

背景

WEBサービスにLINE Loginを実装する際に、ヘッダを指定してGETリクエストを送るのにハマってしまったので、記載。httpartyを使えば、あっさりと書くことができた。

環境

  • Ruby 2.6.2

実装

# httparty.rb
require 'httparty'


@res = HTTParty.get("https://api.line.me/v2/profile", :headers => {"Authorization" => "Bearer #{@response_body['access_token']}"})

参考

https://developers.line.biz/ja/docs/line-login/managing-users/#get-profile
https://gist.github.com/jeffdonthemic/99c4da9daba9a4ee36ba

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0