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")
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")
def test_imap_freshtoken(self): storage = Storage("null.dat") credentials = run(self.flow, storage) os.unlink("null.dat") imap = GMail_IMAP() imap.login_oauth2(USERNAME, credentials=credentials) imap.select("INBOX")
def test_imap_freshtoken(self): storage = Storage("null.dat") credentials = run(self.flow, storage) os.unlink("null.dat") imap = GMail_IMAP() imap.login_oauth2(USERNAME, credentials=credentials) imap.select("INBOX")
def test_JWTServiceAccount(self): f = file(PRIVATE_KEY, "rb") key = f.read() f.close() credentials = SignedJwtAssertionCredentials( service_account_name=SERVICE_ACCOUNT_EMAIL, private_key=key, scope=" ".join(SCOPES), prn=USERNAME ) imap = GMail_IMAP() imap.login_oauth2(USERNAME, credentials=credentials) imap.select("INBOX")
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")
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")
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
def test_JWTServiceAccount(self): f = file(PRIVATE_KEY, 'rb') key = f.read() f.close() credentials = SignedJwtAssertionCredentials(service_account_name=SERVICE_ACCOUNT_EMAIL, private_key=key, scope=" ".join(SCOPES), prn=USERNAME) imap = GMail_IMAP() imap.login_oauth2(USERNAME, credentials=credentials) imap.select("INBOX")
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