#NEWLINE# def to_jwt( self , algorithm = 'HS256' ) : #NEWLINE# #INDENT# now = int ( time . time ( ) ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'typ' : 'JWT' , #NEWLINE# 'cty' : 'twilio-fpa;v=1' , #NEWLINE# #UNINDENT# } #NEWLINE# grants = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if self . identity : #NEWLINE# #INDENT# grants [ 'identity' ] = self . identity #NEWLINE# #UNINDENT# for grant in self . grants : #NEWLINE# #INDENT# grants [ grant . key ] = grant . to_payload ( ) #NEWLINE# #UNINDENT# payload = { #NEWLINE# #INDENT# 'jti' : '{0}-{1}' . format ( self . signing_key_sid , now ) , #NEWLINE# 'iss' : self . signing_key_sid , #NEWLINE# 'sub' : self . account_sid , #NEWLINE# 'exp' : ( now + self . ttl ) , #NEWLINE# 'grants' : grants , #NEWLINE# #UNINDENT# } #NEWLINE# if ( self . nbf is not None ) : #NEWLINE# #INDENT# payload [ 'nbf' ] = self . nbf #NEWLINE# #UNINDENT# return jwt . encode ( payload , self . secret , headers = headers , algorithm = algorithm )