Class: Google::APIClient::JWTAsserter Deprecated
- Inherits:
-
Object
- Object
- Google::APIClient::JWTAsserter
- Defined in:
- lib/google/api_client/auth/jwt_asserter.rb
Overview
Service accounts are now supported directly in Signet
Generates access tokens using the JWT assertion profile. Requires a service account & access to the private key.
Instance Attribute Summary collapse
-
#algorithm ⇒ String
Algorithm used for signing.
-
#expiry ⇒ Fixnum
How long, in seconds, the assertion is valid for.
-
#issuer ⇒ String
ID/email of the issuing party.
-
#key ⇒ String, OpenSSL::PKey
writeonly
Key for signing assertions.
-
#scope ⇒ String
Scopes to authorize.
-
#skew ⇒ Fixnum
Seconds to expand the issued at/expiry window to account for clock skew.
Instance Method Summary collapse
-
#authorize(person = nil, options = {}) ⇒ Signet::OAuth2::Client
Request a new access token.
-
#initialize(issuer, scope, key, algorithm = "RS256") ⇒ JWTAsserter
constructor
Initializes the asserter for a service account.
-
#to_authorization(person = nil) ⇒ Signet::OAuth2::Client
Builds a Signet OAuth2 client.
Constructor Details
#initialize(issuer, scope, key, algorithm = "RS256") ⇒ JWTAsserter
Initializes the asserter for a service account.
66 67 68 69 70 71 72 73 |
# File 'lib/google/api_client/auth/jwt_asserter.rb', line 66 def initialize(issuer, scope, key, algorithm = "RS256") self.issuer = issuer self.scope = scope self.expiry = 60 # 1 min default self.skew = 60 self.key = key self.algorithm = algorithm end |
Instance Attribute Details
#algorithm ⇒ String
Returns Algorithm used for signing.
52 53 54 |
# File 'lib/google/api_client/auth/jwt_asserter.rb', line 52 def algorithm @algorithm end |
#expiry ⇒ Fixnum
Returns How long, in seconds, the assertion is valid for.
44 45 46 |
# File 'lib/google/api_client/auth/jwt_asserter.rb', line 44 def expiry @expiry end |
#issuer ⇒ String
Returns ID/email of the issuing party.
42 43 44 |
# File 'lib/google/api_client/auth/jwt_asserter.rb', line 42 def issuer @issuer end |
#key=(value) ⇒ String, OpenSSL::PKey (writeonly)
Returns key for signing assertions.
50 51 52 |
# File 'lib/google/api_client/auth/jwt_asserter.rb', line 50 def key=(value) @key = value end |
#scope ⇒ String
Returns Scopes to authorize.
48 49 50 |
# File 'lib/google/api_client/auth/jwt_asserter.rb', line 48 def scope @scope end |
#skew ⇒ Fixnum
Returns Seconds to expand the issued at/expiry window to account for clock skew.
46 47 48 |
# File 'lib/google/api_client/auth/jwt_asserter.rb', line 46 def skew @skew end |
Instance Method Details
#authorize(person = nil, options = {}) ⇒ Signet::OAuth2::Client
Request a new access token.
103 104 105 106 107 |
# File 'lib/google/api_client/auth/jwt_asserter.rb', line 103 def (person = nil, ={}) = self.(person) .fetch_access_token!() return end |
#to_authorization(person = nil) ⇒ Signet::OAuth2::Client
Builds a Signet OAuth2 client
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/google/api_client/auth/jwt_asserter.rb', line 113 def (person = nil) return Signet::OAuth2::Client.new( :token_credential_uri => 'https://accounts.google.com/o/oauth2/token', :audience => 'https://accounts.google.com/o/oauth2/token', :scope => self.scope, :issuer => @issuer, :signing_key => @key, :signing_algorithm => @algorithm, :person => person ) end |