Sha256: f05e94795d5f14fbb72436077ac1b4f9c7293de9293d1712e14b5f3ce286bd3e
Contents?: true
Size: 915 Bytes
Versions: 3
Compression:
Stored size: 915 Bytes
Contents
module Imgur module Rake extend self AUTHORIZE_ENDPOINT = '/oauth2/authorize' TOKEN_ENDPOINT = '/oauth2/token' def authorize(client_id, client_secret) connection = Faraday.new(HOST) puts "\nVisit this URL: #{HOST}#{AUTHORIZE_ENDPOINT}?client_id=#{client_id}&response_type=pin" print 'And after you approved the authorization please enter your verification code: ' pin = STDIN.gets.strip begin response = JSON.parse connection.post(TOKEN_ENDPOINT, pin: pin, client_id: client_id, client_secret: client_secret, grant_type: 'pin').body rescue puts "Authorization failed.\nPlease try again." exit end puts <<-MESSAGE Authorization was successful. Use these credentials to initialize the library: access_token: #{response['access_token']} refresh_secret: #{response['refresh_token']} MESSAGE end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
imgurapi-2.0.2 | lib/imgur/tasks/rake.rb |
imgurapi-2.0.1 | lib/imgur/tasks/rake.rb |
imgurapi-2.0.0 | lib/imgur/tasks/rake.rb |