Top Level Namespace
Defined Under Namespace
Classes: FranklyClient
Instance Method Summary collapse
-
#generate_identity_token(app_key, app_secret, nonce, user_id = nil, role = nil) ⇒ String
This function generates an identity token suitable for a single authentication attempt of a client against the Frankly API or SDK.
Instance Method Details
#generate_identity_token(app_key, app_secret, nonce, user_id = nil, role = nil) ⇒ String
This function generates an identity token suitable for a single authentication attempt of a client against the Frankly API or SDK
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/frankly-ruby.rb', line 243 def generate_identity_token(app_key, app_secret, nonce, user_id = nil, role = nil) auth_header = { typ: 'JWS', alg: 'HS256', cty: 'frankly-it;v1' } auth_claims = { aak: app_key, iat: Time.now.to_i, exp: Time.now.to_i + 10 * 24 * 60 * 60, nce: nonce } auth_claims[:uid] = user_id unless user_id.nil? auth_claims[:role] = role unless role.nil? JWT.encode(auth_claims, app_secret, 'HS256', auth_header) end |