Module: Mural::Client::Authentication
- Included in:
- Mural::Client
- Defined in:
- lib/mural/client/authentication.rb
Instance Method Summary collapse
Instance Method Details
#authorize_url ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/mural/client/authentication.rb', line 6 def URI::HTTPS.build( host: host, path: '/api/public/v1/authorization/oauth2/', query: URI.encode_www_form() ).to_s end |
#refresh ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mural/client/authentication.rb', line 29 def refresh uri = URI::HTTPS.build( host: host, path: '/api/public/v1/authorization/oauth2/token' ) res = Net::HTTP.post_form(uri, refresh_token_payload) json = JSON.parse res.body @access_token = json['access_token'] @refresh_token = json['refresh_token'] nil end |
#request_token(code) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mural/client/authentication.rb', line 14 def request_token(code) uri = URI::HTTPS.build( host: host, path: '/api/public/v1/authorization/oauth2/token' ) res = Net::HTTP.post_form(uri, request_token_payload(code)) data = JSON.parse res.body @access_token = data['access_token'] @refresh_token = data['refresh_token'] data end |