Esempio n. 1
0
    def test_imap_noaccesstoken(self):
        # the library should detect the lack of access token, and use the refresh token to go get a new one.
        self.credentials.access_token = None

        imap = GMail_IMAP()
        imap.debug = 4
        imap.login_oauth2(USERNAME, credentials=self.credentials)
        imap.select("INBOX")
Esempio n. 2
0
    def test_imap_noaccesstoken(self):
        # the library should detect the lack of access token, and use the refresh token to go get a new one.
        self.credentials.access_token = None

        imap = GMail_IMAP()
        imap.debug = 4
        imap.login_oauth2(USERNAME, credentials=self.credentials)
        imap.select("INBOX")
Esempio n. 3
0
    def test_imap_fromexpiredclientsecrets(self):

        # fake an expired token
        self.credentials.token_expiry = datetime.datetime(2012, 2, 10, 20, 59, 34)

        old_access_token = self.credentials.access_token

        imap = GMail_IMAP()
        imap.debug = 4
        imap.login_oauth2(USERNAME, credentials=self.credentials)
        imap.select("INBOX")

        self.assertNotEqual(old_access_token, imap._credentials.access_token, "We should have a new AccessToken")
Esempio n. 4
0
    def test_imap_fromexpiredclientsecrets(self):

        # fake an expired token
        self.credentials.token_expiry = datetime.datetime(2012, 2, 10, 20, 59, 34)

        old_access_token = self.credentials.access_token

        imap = GMail_IMAP()
        imap.debug = 4
        imap.login_oauth2(USERNAME, credentials=self.credentials)
        imap.select("INBOX")

        self.assertNotEqual(old_access_token, imap._credentials.access_token, "We should have a new AccessToken")
Esempio n. 5
0
    def setUp(self):
        self.flow = flow_from_clientsecrets(filename=BASEDIR + "/client_secrets.json", scope=" ".join(SCOPES))

        storage = Storage("auth_secrets.dat")
        credentials = storage.get()
        if credentials is None or credentials.invalid:
            credentials = run(self.flow, storage)
        self.credentials = credentials

        imap = GMail_IMAP()
        imap.debug = 4
        imap.login_oauth2(USERNAME, credentials=self.credentials)
        imap.select("INBOX")
        self.imap = imap
Esempio n. 6
0
    def setUp(self):
        self.flow = flow_from_clientsecrets(filename=BASEDIR + "/client_secrets.json",
                                            scope=" ".join(SCOPES))

        storage = Storage("auth_secrets.dat")
        credentials = storage.get()
        if credentials is None or credentials.invalid:
            credentials = run(self.flow, storage)
        self.credentials = credentials

        imap = GMail_IMAP()
        imap.debug = 4
        imap.login_oauth2(USERNAME, credentials=self.credentials)
        imap.select("INBOX")
        self.imap = imap