@@ -58,20 +58,23 @@ def signed_session(self):
58
58
return basic_authentication .signed_session ()
59
59
60
60
def get_access_token (self , force_refresh = False ):
61
- if not force_refresh :
62
- # check the global cache for the token. If we have it, and it's valid, we're done.
63
- oauth_token = MicrosoftAppCredentials .cache .get (self .token_cache_key , None )
64
- if oauth_token is not None :
65
- # we have the token. Is it valid?
66
- if oauth_token .expiration_time > datetime .now ():
67
- return oauth_token .access_token
68
- # We need to refresh the token, because:
69
- # 1. The user requested it via the force_refresh parameter
70
- # 2. We have it, but it's expired
71
- # 3. We don't have it in the cache.
72
- oauth_token = self .refresh_token ()
73
- MicrosoftAppCredentials .cache .setdefault (self .token_cache_key , oauth_token )
74
- return oauth_token .access_token
61
+ if self .microsoft_app_id and self .microsoft_app_password :
62
+ if not force_refresh :
63
+ # check the global cache for the token. If we have it, and it's valid, we're done.
64
+ oauth_token = MicrosoftAppCredentials .cache .get (self .token_cache_key , None )
65
+ if oauth_token is not None :
66
+ # we have the token. Is it valid?
67
+ if oauth_token .expiration_time > datetime .now ():
68
+ return oauth_token .access_token
69
+ # We need to refresh the token, because:
70
+ # 1. The user requested it via the force_refresh parameter
71
+ # 2. We have it, but it's expired
72
+ # 3. We don't have it in the cache.
73
+ oauth_token = self .refresh_token ()
74
+ MicrosoftAppCredentials .cache .setdefault (self .token_cache_key , oauth_token )
75
+ return oauth_token .access_token
76
+ else :
77
+ return ''
75
78
76
79
def refresh_token (self ):
77
80
options = {
0 commit comments