當前位置: 首頁>>代碼示例>>Python>>正文


Python GmailAccount.set_access_token方法代碼示例

本文整理匯總了Python中inbox.models.backends.gmail.GmailAccount.set_access_token方法的典型用法代碼示例。如果您正苦於以下問題:Python GmailAccount.set_access_token方法的具體用法?Python GmailAccount.set_access_token怎麽用?Python GmailAccount.set_access_token使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在inbox.models.backends.gmail.GmailAccount的用法示例。


在下文中一共展示了GmailAccount.set_access_token方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_account

# 需要導入模塊: from inbox.models.backends.gmail import GmailAccount [as 別名]
# 或者: from inbox.models.backends.gmail.GmailAccount import set_access_token [as 別名]
def create_account(db_session, email_address, response):
    # See if the account exists in db, otherwise create it
    try:
        account = db_session.query(GmailAccount) \
            .filter_by(email_address=email_address).one()
    except NoResultFound:
        namespace = Namespace()
        account = GmailAccount(namespace=namespace)

    tok = response.get('access_token')
    expires_in = response.get('expires_in')
    account.set_access_token(tok, expires_in)
    account.refresh_token = response.get('refresh_token')
    account.scope = response.get('scope')
    account.email_address = response.get('email')
    account.family_name = response.get('family_name')
    account.given_name = response.get('given_name')
    account.name = response.get('name')
    account.gender = response.get('gender')
    account.g_id = response.get('id')
    account.g_user_id = response.get('user_id')
    account.g_id_token = response.get('id_token')
    account.link = response.get('link')
    account.locale = response.get('locale')
    account.picture = response.get('picture')
    account.home_domain = response.get('hd')
    account.client_id = response.get('client_id')
    account.client_secret = response.get('client_secret')

    return account
開發者ID:chengjunjian,項目名稱:inbox,代碼行數:32,代碼來源:gmail.py

示例2: create_account

# 需要導入模塊: from inbox.models.backends.gmail import GmailAccount [as 別名]
# 或者: from inbox.models.backends.gmail.GmailAccount import set_access_token [as 別名]
    def create_account(self, db_session, email_address, response):
        email_address = response.get('email')
        # See if the account exists in db, otherwise create it
        try:
            account = db_session.query(GmailAccount) \
                .filter_by(email_address=email_address).one()
        except NoResultFound:
            namespace = Namespace()
            account = GmailAccount(namespace=namespace)

        # We only get refresh tokens on initial login (or failed credentials)
        # otherwise, we don't force the login screen and therefore don't get a
        # refresh token back from google.
        new_refresh_token = response.get('refresh_token')
        if new_refresh_token:
            account.refresh_token = new_refresh_token
        else:
            if not account.refresh_token or account.sync_state == 'invalid':
                # We got a new auth without a refresh token, so we need to back
                # out and force the auth flow, since we don't already have
                # a refresh (or the one we have doesn't work.)
                raise OAuthError("Missing refresh token")

        tok = response.get('access_token')
        expires_in = response.get('expires_in')
        account.set_access_token(tok, expires_in)
        account.scope = response.get('scope')
        account.email_address = email_address
        account.family_name = response.get('family_name')
        account.given_name = response.get('given_name')
        account.name = response.get('name')
        account.gender = response.get('gender')
        account.g_id = response.get('id')
        account.g_user_id = response.get('user_id')
        account.g_id_token = response.get('id_token')
        account.link = response.get('link')
        account.locale = response.get('locale')
        account.picture = response.get('picture')
        account.home_domain = response.get('hd')
        account.client_id = response.get('client_id')
        account.client_secret = response.get('client_secret')
        account.sync_contacts = response.get('contacts', True)
        account.sync_events = response.get('events', True)

        try:
            self.verify_config(account)
        except GmailSettingError as e:
            raise UserRecoverableConfigError(e)

        # Hack to ensure that account syncs get restarted if they were stopped
        # because of e.g. invalid credentials and the user re-auths.
        # TODO(emfree): remove after status overhaul.
        if account.sync_state != 'running':
            account.sync_state = None

        return account
開發者ID:bsorin,項目名稱:inbox,代碼行數:58,代碼來源:gmail.py

示例3: create_account

# 需要導入模塊: from inbox.models.backends.gmail import GmailAccount [as 別名]
# 或者: from inbox.models.backends.gmail.GmailAccount import set_access_token [as 別名]
def create_account(db_session, response):
    email_address = response.get('email')
    # See if the account exists in db, otherwise create it
    try:
        account = db_session.query(GmailAccount) \
            .filter_by(email_address=email_address).one()
    except NoResultFound:
        namespace = Namespace()
        account = GmailAccount(namespace=namespace)

    # We only get refresh tokens on initial login (or failed credentials)
    # otherwise, we don't force the login screen and therefore don't get a
    # refresh token back from google.
    new_refresh_token = response.get('refresh_token')
    if new_refresh_token:
        account.refresh_token = new_refresh_token

    tok = response.get('access_token')
    expires_in = response.get('expires_in')
    account.set_access_token(tok, expires_in)
    account.scope = response.get('scope')
    account.email_address = email_address
    account.family_name = response.get('family_name')
    account.given_name = response.get('given_name')
    account.name = response.get('name')
    account.gender = response.get('gender')
    account.g_id = response.get('id')
    account.g_user_id = response.get('user_id')
    account.g_id_token = response.get('id_token')
    account.link = response.get('link')
    account.locale = response.get('locale')
    account.picture = response.get('picture')
    account.home_domain = response.get('hd')
    account.client_id = response.get('client_id')
    account.client_secret = response.get('client_secret')

    return account
開發者ID:Dracophoenix1,項目名稱:inbox,代碼行數:39,代碼來源:gmail.py


注:本文中的inbox.models.backends.gmail.GmailAccount.set_access_token方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。