Class: Pinnacle::Network::SilentAuth::Client
- Inherits:
-
Object
- Object
- Pinnacle::Network::SilentAuth::Client
- Defined in:
- lib/pinnacle/network/silent_auth/client.rb
Instance Method Summary collapse
-
#check(request_options: {}, **params) ⇒ Pinnacle::Types::SilentAuthCheckResponse
Complete a Silent Authentication request by exchanging the code returned from the JSON flow.
- #initialize(client:) ⇒ void constructor
-
#start(request_options: {}, **params) ⇒ Pinnacle::Types::SilentAuthResponse
Start a Silent Authentication session to verify that the user controls the device attached to a phone number.
Constructor Details
#initialize(client:) ⇒ void
10 11 12 |
# File 'lib/pinnacle/network/silent_auth/client.rb', line 10 def initialize(client:) @client = client end |
Instance Method Details
#check(request_options: {}, **params) ⇒ Pinnacle::Types::SilentAuthCheckResponse
Complete a Silent Authentication request by exchanging the code returned from the JSON flow. Call this from your server after the user’s mobile app fetches ‘jsonUrl`.
This endpoint returns a terminal verification result. To inspect pending lifecycle states such as ‘started` or `challenge-issued`, use [Get Network Request](/api-reference/network/get-network-request).
<Note>
Limited availability. Contact [founders@pinnacle.sh](mailto:founders@pinnacle.sh) to request access.
</Note>
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/pinnacle/network/silent_auth/client.rb', line 78 def check(request_options: {}, **params) params = Pinnacle::Internal::Types::Utils.normalize_keys(params) request_data = Pinnacle::Network::SilentAuth::Types::SilentAuthCheckRequest.new(params).to_h non_body_param_names = %w[requestId] body = request_data.except(*non_body_param_names) request = Pinnacle::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "network/silent-auth/#{URI.encode_uri_component(params[:request_id].to_s)}/check", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Pinnacle::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Pinnacle::Types::SilentAuthCheckResponse.load(response.body) else error_class = Pinnacle::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#start(request_options: {}, **params) ⇒ Pinnacle::Types::SilentAuthResponse
Start a Silent Authentication session to verify that the user controls the device attached to a phone number. Omit ‘format` to receive a `browserUrl` for the hosted browser/WebView flow, or set `format: “json”` to receive a `jsonUrl` for a native mobile app or custom client-side flow. The device check must run from the user’s cellular device, not your server.
The returned URL expires 60 seconds after creation. Open or fetch it immediately and use ‘expiresAt` to detect when a new Silent Auth session is required.
<Note>
Limited availability. Contact [founders@pinnacle.sh](mailto:founders@pinnacle.sh) to request access.
</Note>
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/pinnacle/network/silent_auth/client.rb', line 35 def start(request_options: {}, **params) params = Pinnacle::Internal::Types::Utils.normalize_keys(params) request = Pinnacle::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "network/silent-auth", body: Pinnacle::Network::SilentAuth::Types::SilentAuthRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Pinnacle::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Pinnacle::Types::SilentAuthResponse.load(response.body) else error_class = Pinnacle::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |