def generate_jwt():
 now = int(time.time())
 header_json = json.dumps({'typ': 'JWT', 'alg': 'RS256'})
 payload_json = json.dumps({'iat': now, 'exp': (now + 3600), 'iss': DEFAUTL_SERVICE_ACCOUNT, 'scope': TARGET_AUD, 'aud': 'https://www.googleapis.com/oauth2/v4/token'})
 headerAndPayload = '{}.{}'.format(base64.urlsafe_b64encode(header_json), base64.urlsafe_b64encode(payload_json))
 (key_name, signature) = app_identity.sign_blob(headerAndPayload)
 signed_jwt = '{}.{}'.format(headerAndPayload, base64.urlsafe_b64encode(signature))
 return signed_jwt

def generate_jwt ( ) : now = int ( time . time ( ) ) header_json = json . dumps ( { 'typ' : 'JWT' , 'alg' : 'RS256' } ) payload_json = json . dumps ( { 'iat' : now , 'exp' : ( now + 3600 ) , 'iss' : DEFAUTL_SERVICE_ACCOUNT , 'scope' : TARGET_AUD , 'aud' : 'https://www.googleapis.com/oauth2/v4/token' } ) headerAndPayload = '{}.{}' . format ( base64 . urlsafe_b64encode ( header_json ) , base64 . urlsafe_b64encode ( payload_json ) ) ( key_name , signature ) = app_identity . sign_blob ( headerAndPayload ) signed_jwt = '{}.{}' . format ( headerAndPayload , base64 . urlsafe_b64encode ( signature ) ) return signed_jwt
generates a signed json web token using the google app engine default service account .