Oauth Lookup

enum q2_sdk.hq.db.oauth_lookup.TokenType(value)[source]

Bases: Enum

Valid values are as follows:

Access = <TokenType.Access: 'Access'>
Authorization = <TokenType.Authorization: 'Authorization'>
Refresh = <TokenType.Refresh: 'Refresh'>
class q2_sdk.hq.db.oauth_lookup.OAuthLookupDataRow(element, row_class=None, rename_fields=None)[source]

Bases: TableRow

OAuthLookupKeyID: int
OAuthLookupKeyName: str
UserID_: int
CustomerID_: int
accessToken: str
Expiry: str
class q2_sdk.hq.db.oauth_lookup.RefreshTokenParameters(access_token, refresh_token, scope, expiry, client_id, user_id, customer_id=None, disable_list=None)[source]

Bases: object

Parameters:
  • access_token (str) – The new access token to be inserted into the database

  • refresh_token (str) – The new refresh token to be inserted into the database

  • scope (list | dict | str) – The scope value for the new entity

  • expiry (datetime) – The time the new access token expires

  • client_id (str) – The client ID for the new access and refresh tokens

  • user_id (int) – The user ID for the new tokens

  • customer_id (Optional[int]) – The customer ID for the new tokens. Not typically used and is defaulted to -1

  • disable_list (Optional[list]) – A list of dictionaries containing oauth token ids that will be disabled as part of this refresh process. ex: [{“id”: 1}, {“id”, 2}]

access_token: str
refresh_token: str
scope: list | dict | str
expiry: datetime
client_id: str
user_id: int
customer_id: Optional[int] = None
disable_list: Optional[list] = None
get_sql_param_list()[source]
Return type:

list

class q2_sdk.hq.db.oauth_lookup.RefreshTokenResults(new_access_token_id, new_refresh_token_id)[source]

Bases: object

RefreshTokenResults(new_access_token_id: int, new_refresh_token_id: int)

new_access_token_id: int
new_refresh_token_id: int
class q2_sdk.hq.db.oauth_lookup.OAuthLookup(logger, hq_credentials=None, ret_table_obj=None)[source]

Bases: DbObject

Programmatic access to the Q2 database. Not as flexible as a true ORM, but takes the guesswork out of database schemas and ensures safety in the transactions.

Parameters:
  • logger – Reference to calling request’s logger (self.logger in your extension)

  • hq_credentials (Optional[HqCredentials]) – HQ Connectivity Information (Defaults to settings file)

  • ret_table_obj (Optional[bool]) – Flag to return list of LXML elements if False or TableRow objects from DB calls if True (Defaults to settings file)

REPRESENTATION_ROW_CLASS

alias of OAuthLookupDataRow

add_arguments(parser)[source]

Hook for subclassed DbObjects to add custom arguments.

async get(clientid, user_id=None, customer_id=None, token_type='Access', enabled_only='True', no_trunc=False, serialize_for_cli=False)[source]
Return type:

List[OAuthLookupDataRow]

async get_by_user(user_id=None, customer_id=None, no_trunc=False, serialize_for_cli=False)[source]
async get_by_id(oauth_lookup_id, no_trunc=False, serialize_for_cli=False)[source]
async get_by_value(clientid, access_token, enabled_only='True', token_type='Access', no_trunc=False, serialize_for_cli=False)[source]
Return type:

List[OAuthLookupDataRow]

async add_update(customer_id, user_id, clientid, access_token, token_type='Access', scope=None, expiry=None, parent_client=None)[source]
async enable(customer_id=-1, user_id=-1, clientid=None, access_token=None, token_type='Access', oauthtokenid=-1)[source]
async disable(customer_id=-1, user_id=-1, clientid=None, access_token=None, token_type='Access', oauthtokenid=-1)[source]
async delete(clientid, customer_id, user_id, access_token, online_session, online_user, token_type='Access')[source]
async refresh_token(parameter_object)[source]

A single process for the refresh token flow. This method does not specifically audit.

Return type:

RefreshTokenResults