Sha256: f6bb071bda055a5c7e4d3ddadc5cdd9e3f2a2bd8f9bd6e0277d9f3e6259b02a1
Contents?: true
Size: 894 Bytes
Versions: 12
Compression:
Stored size: 894 Bytes
Contents
module Oauth class Provider < ActiveRecord::Base self.table_name = "oauth_providers" validates :name, :site, :authorize_path, :token_path, :client_id, :client_secret, presence: true def authorize_url(params={}) client.auth_code.authorize_url params.merge(redirect_uri: oauth2_callback_url) end def redeem_access_token(code, params={}) client.auth_code.get_token(code, params.merge(redirect_uri: oauth2_callback_url)) end def refresh_access_token(authorization) OAuth2::AccessToken.from_hash(client, authorization.attributes).refresh! end private def client @client ||= OAuth2::Client.new( client_id, client_secret, site: site, authorize_url: authorize_path, token_url: token_path) end def oauth2_callback_url "http://#{Houston.host}/oauth2/callback" end end end
Version data entries
12 entries across 12 versions & 1 rubygems