Method: SelfSDK::Services::Authentication#request
- Defined in:
- lib/services/auth.rb
#request(selfid, opts = {}) {|request| ... } ⇒ String #request(selfid, opts = {}) ⇒ String
Sends an authentication request to the specified selfid. An authentication requests allows your users to authenticate on your app using a secure self app.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/services/auth.rb', line 40 def request(selfid, opts = {}, &block) SelfSDK.logger.info "authenticating #{selfid}" rq = opts.fetch(:request, true) if rq raise "You're not permitting connections from #{selfid}" unless @messaging_service.is_permitted?(selfid) end req = SelfSDK::Messages::AuthenticationReq.new(@messaging) req.populate(selfid, opts) body = @client.jwt.prepare(req.body) return body unless rq return req. if opts.fetch(:async, false) # when a block is given the request will always be asynchronous. if block_given? @messaging.set_observer(req, timeout: req.exp_timeout, &block) return req. end # Otherwise the request is synchronous req.request end |