# @return [Object] Storage object.
attr_accessor :store
-
# @return [Signet::OAuth2::Client]
attr_reader :authorization
end
##
- # Attempt to read in credentials from the specified store.
- def load_credentials
- store.load_credentials
+ # Write the credentials to the specified store.
+ #
+ # @params [Signet::OAuth2::Client] authorization
+ # Optional authorization instance. If not provided, the authorization
+ # already associated with this instance will be written.
+ def write_credentials(authorization=nil)
+ @authorization = authorization if authorization
+ if @authorization.refresh_token
+ store.write_credentials(credentials_hash)
+ end
end
def authorize
self.write_credentials
end
+ private
+
+ ##
+ # Attempt to read in credentials from the specified store.
+ def load_credentials
+ store.load_credentials
+ end
+
##
# @return [Hash] with credentials
def credentials_hash
:issued_at => @authorization.issued_at.to_i
}
end
-
- ##
- # Write the credentials to the specified store.
- #
- # @params [Signet::OAuth2::Client] authorization
- # Optional authorization instance. If not provided, the authorization
- # already associated with this instance will be written.
- def write_credentials(authorization=nil)
- @authorization = authorization if authorization
- if @authorization.refresh_token
- store.write_credentials(credentials_hash)
- end
- end
end
end
end