Class: Google::IdentityToolkit::Api
- Inherits:
-
Object
- Object
- Google::IdentityToolkit::Api
- Includes:
- HTTParty
- Defined in:
- lib/google/identity_toolkit/api.rb
Overview
Server API for creating login requests & verifying assertions
Instance Method Summary collapse
-
#initialize(api_key) ⇒ Api
constructor
Initializes the API.
-
#verify_assertion(request_uri, body = nil) ⇒ Hash
Sends an IDP response for verification, returning an assertion if the response is valid.
Constructor Details
#initialize(api_key) ⇒ Api
Initializes the API
20 21 22 |
# File 'lib/google/identity_toolkit/api.rb', line 20 def initialize(api_key) @api_key = api_key end |
Instance Method Details
#verify_assertion(request_uri, body = nil) ⇒ Hash
Sends an IDP response for verification, returning an assertion if the response is valid
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/google/identity_toolkit/api.rb', line 38 def verify_assertion(request_uri, body=nil) request = { "requestUri" => request_uri } request["postBody"] = body.gets unless body.nil? response = Api.post('https://www.googleapis.com/identitytoolkit/v1/relyingparty/verifyAssertion', :query => { "key" => @api_key }, :body => request.to_json ) raise ApiError.new("Error #{response.code} when verifying the assertion") unless response.code == 200 response.parsed_response end |