class ChinoRuby::Auth
Public Instance Methods
login_authentication_code(code, redirect_url, application_id, application_secret)
click to toggle source
# File lib/chino_ruby/classes.rb, line 366 def login_authentication_code(code, redirect_url, application_id, application_secret) check_string(code) check_string(redirect_url) check_string(application_id) check_string(application_secret) uri = return_uri("/auth/token/") req = Net::HTTP::Post.new(uri.path) req.basic_auth application_id, application_secret req.set_form_data([["code", code], ["redirect_uri", redirect_url], ["grant_type", "authorization_code"], ["scope", "read write"], ["client_id", application_id], ["client_secret", application_secret]]) res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) {|http| http.request(req) } usr = LoggedUser.new usr.from_json((parse_response(res)['data']).to_json) usr end
login_password(username, password, application_id, application_secret)
click to toggle source
# File lib/chino_ruby/classes.rb, line 349 def login_password(username, password, application_id, application_secret) check_string(username) check_string(password) check_string(application_id) check_string(application_secret) uri = return_uri("/auth/token/") req = Net::HTTP::Post.new(uri.path) req.basic_auth application_id, application_secret req.set_form_data([["username", username], ["password", password], ["grant_type", "password"]]) res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) {|http| http.request(req) } usr = LoggedUser.new usr.from_json((parse_response(res)['data']).to_json) usr end
logout(token, application_id, application_secret)
click to toggle source
# File lib/chino_ruby/classes.rb, line 399 def logout(token, application_id, application_secret) check_string(token) check_string(application_id) check_string(application_secret) uri = return_uri("/auth/revoke_token/") req = Net::HTTP::Post.new(uri.path) req.basic_auth application_id, application_secret req.set_form_data([["token", token], ["client_id", application_id], ["client_secret", application_secret]]) res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) {|http| http.request(req) } parse_response(res)['result'] end
refresh_token(refresh_token, application_id, application_secret)
click to toggle source
# File lib/chino_ruby/classes.rb, line 383 def refresh_token(refresh_token, application_id, application_secret) check_string(refresh_token) check_string(application_id) check_string(application_secret) uri = return_uri("/auth/token/") req = Net::HTTP::Post.new(uri.path) req.basic_auth application_id, application_secret req.set_form_data([["refresh_token", refresh_token], ["client_id", application_id], ["client_secret", application_secret], ["grant_type", "refresh_token"]]) res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) {|http| http.request(req) } usr = LoggedUser.new usr.from_json((parse_response(res)['data']).to_json) usr end