示例#1
0
 def authorize(self, request):
   with self._lock:
     # Load from cache on a first access.
     if not self._access_token:
       self._access_token = oauth.load_access_token(self.urlhost, self.config)
     # Refresh if expired.
     need_refresh = True
     if self._access_token:
       if self._access_token.expires_at is not None:
         # Allow 5 min of clock skew.
         now = datetime.datetime.utcnow() + datetime.timedelta(seconds=300)
         need_refresh = now >= self._access_token.expires_at
       else:
         # Token without expiration time never expired.
         need_refresh = False
     if need_refresh:
       self._access_token = oauth.create_access_token(
           self.urlhost, self.config, False)
     if self._access_token:
       request.headers['Authorization'] = (
           'Bearer %s' % self._access_token.token)
示例#2
0
 def authorize(self, request):
     with self._lock:
         # Load from cache on a first access.
         if not self._access_token:
             self._access_token = oauth.load_access_token(
                 self.urlhost, self.config)
         # Refresh if expired.
         need_refresh = True
         if self._access_token:
             if self._access_token.expires_at is not None:
                 # Allow 5 min of clock skew.
                 now = datetime.datetime.utcnow() + datetime.timedelta(
                     seconds=300)
                 need_refresh = now >= self._access_token.expires_at
             else:
                 # Token without expiration time never expired.
                 need_refresh = False
         if need_refresh:
             self._access_token = oauth.create_access_token(
                 self.urlhost, self.config, False)
         if self._access_token:
             request.headers['Authorization'] = ('Bearer %s' %
                                                 self._access_token.token)
示例#3
0
 def login(self, allow_user_interaction):
   with self._lock:
     self._access_token = oauth.create_access_token(
         self.urlhost, self.options, allow_user_interaction)
     return self._access_token is not None
示例#4
0
 def login(self, allow_user_interaction):
     with self._lock:
         # Forcefully refresh the token.
         self._access_token = oauth.create_access_token(
             self.urlhost, self.config, allow_user_interaction)
         return self._access_token is not None
示例#5
0
 def login(self, allow_user_interaction):
   with self._lock:
     # Forcefully refresh the token.
     self._access_token = oauth.create_access_token(
         self.urlhost, self.config, allow_user_interaction)
     return self._access_token is not None
示例#6
0
文件: net.py 项目: danfengzi/soui_gyp
 def login(self, allow_user_interaction):
     with self._lock:
         self._access_token = oauth.create_access_token(
             self.urlhost, self.config, allow_user_interaction)
         self._access_token_known = True
         return self._access_token is not None
示例#7
0
文件: net.py 项目: wacr2008/soui_gyp
 def login(self, allow_user_interaction):
   with self._lock:
     self._access_token = oauth.create_access_token(
         self.urlhost, self.config, allow_user_interaction)
     self._access_token_known = True
     return self._access_token is not None