Class: Android::Publisher::Secrets
- Inherits:
-
Object
- Object
- Android::Publisher::Secrets
- Defined in:
- lib/android/publisher/secrets.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#authorization_uri ⇒ Object
readonly
Returns the value of attribute authorization_uri.
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
readonly
Returns the value of attribute client_secret.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#expires_in ⇒ Object
readonly
Returns the value of attribute expires_in.
-
#flow ⇒ Object
readonly
Returns the value of attribute flow.
-
#id_token ⇒ Object
readonly
Returns the value of attribute id_token.
-
#issued_at ⇒ Object
readonly
Returns the value of attribute issued_at.
-
#javascript_origins ⇒ Object
readonly
Returns the value of attribute javascript_origins.
-
#redirect_uris ⇒ Object
readonly
Returns the value of attribute redirect_uris.
-
#refresh_token ⇒ Object
readonly
Returns the value of attribute refresh_token.
-
#token_credential_uri ⇒ Object
readonly
Returns the value of attribute token_credential_uri.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Secrets
constructor
Intialize OAuth client settings.
- #to_authorized_connection ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Secrets
Intialize OAuth client settings.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/android/publisher/secrets.rb', line 48 def initialize(={}) @flow = [:flow] || .keys.first.to_s || 'web' fdata = [@flow] # Client auth config @client_id = fdata[:client_id] || fdata["client_id"] @client_secret = fdata[:client_secret] || fdata["client_secret"] # Redirects info @redirect_uris = fdata[:redirect_uris] || fdata["redirect_uris"] || [fdata[:redirect_uri]] @javascript_origins = fdata[:javascript_origins] || fdata["javascript_origins"]|| [fdata[:javascript_origin]] # Endpoints info = URI.parse(fdata[:auth_uri] || fdata["auth_uri"] || fdata[:authorization_uri]) @token_credential_uri = URI.parse(fdata[:token_uri] || fdata["token_uri"] || fdata[:token_credential_uri]) # Associated token info @access_token = fdata[:access_token] || fdata["access_token"] @refresh_token = fdata[:refresh_token] || fdata["refresh_token"] @id_token = fdata[:id_token] || fdata["id_token"] @expires_in = fdata[:expires_in] || fdata["expires_in"] @expires_at = fdata[:expires_at] || fdata["expires_at"] @issued_at = fdata[:issued_at] || fdata["issued_at"] end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
73 74 75 |
# File 'lib/android/publisher/secrets.rb', line 73 def access_token @access_token end |
#authorization_uri ⇒ Object (readonly)
Returns the value of attribute authorization_uri.
73 74 75 |
# File 'lib/android/publisher/secrets.rb', line 73 def end |
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
73 74 75 |
# File 'lib/android/publisher/secrets.rb', line 73 def client_id @client_id end |
#client_secret ⇒ Object (readonly)
Returns the value of attribute client_secret.
73 74 75 |
# File 'lib/android/publisher/secrets.rb', line 73 def client_secret @client_secret end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
73 74 75 |
# File 'lib/android/publisher/secrets.rb', line 73 def expires_at @expires_at end |
#expires_in ⇒ Object (readonly)
Returns the value of attribute expires_in.
73 74 75 |
# File 'lib/android/publisher/secrets.rb', line 73 def expires_in @expires_in end |
#flow ⇒ Object (readonly)
Returns the value of attribute flow.
73 74 75 |
# File 'lib/android/publisher/secrets.rb', line 73 def flow @flow end |
#id_token ⇒ Object (readonly)
Returns the value of attribute id_token.
73 74 75 |
# File 'lib/android/publisher/secrets.rb', line 73 def id_token @id_token end |
#issued_at ⇒ Object (readonly)
Returns the value of attribute issued_at.
73 74 75 |
# File 'lib/android/publisher/secrets.rb', line 73 def issued_at @issued_at end |
#javascript_origins ⇒ Object (readonly)
Returns the value of attribute javascript_origins.
73 74 75 |
# File 'lib/android/publisher/secrets.rb', line 73 def javascript_origins @javascript_origins end |
#redirect_uris ⇒ Object (readonly)
Returns the value of attribute redirect_uris.
73 74 75 |
# File 'lib/android/publisher/secrets.rb', line 73 def redirect_uris @redirect_uris end |
#refresh_token ⇒ Object (readonly)
Returns the value of attribute refresh_token.
73 74 75 |
# File 'lib/android/publisher/secrets.rb', line 73 def refresh_token @refresh_token end |
#token_credential_uri ⇒ Object (readonly)
Returns the value of attribute token_credential_uri.
73 74 75 |
# File 'lib/android/publisher/secrets.rb', line 73 def token_credential_uri @token_credential_uri end |
Class Method Details
.load(filename = nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/android/publisher/secrets.rb', line 28 def self.load(filename=nil) while filename == nil search_path ||= File.('.') if File.exist?(File.join(search_path, 'client_secrets.json')) filename = File.join(search_path, 'client_secrets.json') else raise ArgumentError, 'No client_secrets.json filename supplied ' + 'and/or could not be found in search path.' end end data = File.open(filename, 'r') { |file| JSON.parse(file.read) } return self.new(data) end |
Instance Method Details
#to_authorized_connection ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/android/publisher/secrets.rb', line 79 def # OAuth2::Client.new( # "49761657086.apps.googleusercontent.com", "Cp43nWEtueuPVEKPDJhmr4Mb", # {:site => "https://accounts.android.com/", :authorize_url=>"/o/oauth2/auth", :token_url=>"/o/oauth2/token"} # ) params = { :site => URI.join(, '/'), :authorize_url => .path, :token_url => token_credential_uri.path } client = OAuth2::Client.new(client_id, client_secret, params) token = OAuth2::AccessToken.new(client, access_token, { :refresh_token => refresh_token }) token.refresh! end |