lib/underway/settings.rb in underway-1.0.1 vs lib/underway/settings.rb in underway-1.1.0
- old
+ new
@@ -1,5 +1,6 @@
+require "addressable/uri"
require "pathname"
require "json"
module Underway
class Settings
@@ -71,9 +72,28 @@
@verbose ||= config["verbose_logging"]
end
def token_cache
@token_cache ||= Underway::TokenCache.new(db)
+ end
+
+ def oauth_authorize_url
+ uri = Addressable::URI.parse(config["github_api_host"])
+ "#{uri.scheme}://#{uri.domain}/login/oauth/authorize?client_id=#{config["client_id"]}"
+ end
+
+ def oauth_access_token_url(code)
+ api_host = Addressable::URI.parse(config["github_api_host"])
+ template = Addressable::Template.new(
+ "{scheme}://{host}/login/oauth/access_token{?code,client_id,client_secret}"
+ )
+ template.expand(
+ "scheme" => api_host.scheme,
+ "host" => api_host.domain,
+ "code" => code,
+ "client_id" => config["client_id"],
+ "client_secret" => config["client_secret"]
+ )
end
end
@configuration = Configuration.new