Sha256: 1236a424258dd59de145bcb83de70c0936771af602957be8a17a0599db02ead4
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
require 'oauth' require 'forwardable' require 'debugger' module Sredder class GithubAuth extend Forwardable attr_accessor :sredderc attr_writer :consumer def_delegators :sredderc, :credentials, :credentials= def initialize(sredderc = Sredderc.new) @sredderc = sredderc @sredderc.load end def run_oauth_procedure print "Please enter your github username: " username = $stdin.gets.strip val = `curl -u '#{username}' -d '{"scopes":["repo"],"client_id":"#{client_id}","client_secret":"#{client_secret}"}' https://api.github.com/authorizations` store_tokens(JSON.parse(val)["token"]) end def authorized? !!credentials[:github_token] end def token credentials[:github_token] end private def client_id 'd1f8235b53bd2a2cf37a' end def client_secret 'b0c2923c4db8d2d7ba36dce1dffa00c88fea4159' end def store_tokens(token) self.credentials[:github_token] = token sredderc.save end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sredder-0.0.5 | lib/sredder/github_auth.rb |