Method: OmniAuth::Strategies::WindowsLive::WindowsLiveLogin#processToken

Defined in:
lib/omniauth/strategies/windows_live/windowslivelogin.rb

#processToken(token, context = nil) ⇒ Object

Decodes and validates a Web Authentication token. Returns a User object on success. If a context is passed in, it will be returned as the context field in the User object.



453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
# File 'lib/omniauth/strategies/windows_live/windowslivelogin.rb', line 453

def processToken(token, context=nil)
  if token.nil? or token.empty?
    debug("Error: processToken: Null/empty token.")
    return
  end
  stoken = decodeAndValidateToken token
  stoken = parse stoken
  unless stoken
    debug("Error: processToken: Failed to decode/validate token: #{token}")
    return
  end
  sappid = stoken['appid']
  unless sappid == appid
    debug("Error: processToken: Application ID in token did not match ours: #{sappid}, #{appid}")
    return
  end
  begin
    user = User.new(stoken['ts'], stoken['uid'], stoken['flags'],
                    context, token)
    return user
  rescue Exception => e
    debug("Error: processToken: Contents of token considered invalid: #{e}")
    return
  end
end