Ejemplo n.º 1
0
 def create(self, user, client, refreshable=False, expire=None):
     token = generate_unique_key(
         self.model,
         key_length=appconst.ACCESS_TOKEN_LENGTH,
         key_field='token',
         )
     refresh_token = None
     if refreshable and appsettings.ALLOW_REFRESH_TOKEN:
         refresh_token = generate_unique_key(
             self.model,
             key_length=appconst.REFRESH_TOKEN_LENGTH,
             key_field='refresh_token',
         )
     access_token = self.model(
         token = token,
         refresh_token = refresh_token,
         expire = expire or generate_timestamp(appsettings.ACCESS_TOKEN_EXPIRY),
         client=client,
         user = user,
         )
     access_token.save()
     return access_token
Ejemplo n.º 2
0
 def create(self, user, client, redirect_uri, scope=None, expire=None):
     key = generate_unique_key(
         self.model,
         key_length=appconst.CODE_KEY_LENGTH,
         )
     code = self.model(
         key = key,
         client = client,
         active=True,
         expire = expire or generate_timestamp(appsettings.CODE_EXPIRY),
         redirect_uri = redirect_uri,
         #scope = scope,
         user = user,
         )
     code.save()
     return code
Ejemplo n.º 3
0
 def create(self, response_type, client, redirect_uri=None, state=None, scope=None, expire=None):
     key = generate_unique_key(
         self.model,
         key_length=appconst.AUTHORIZATION_REQUEST_KEY_LENGTH,
         )
     authorization_request = self.model(
         key = key,
         response_type = response_type,
         client = client,
         redirect_uri = redirect_uri,
         state = state,
         expire = expire or generate_timestamp(appsettings.AUTHORIZATION_REQUEST_EXPIRY),
         #scope = ' '.join(scope),
         )
     authorization_request.save()
     return authorization_request
Ejemplo n.º 4
0
def getenerate_client_key():
    return generate_unique_key(Client, key_length=10, key_field='key')