예제 #1
0
    def _get_credentials(self) -> dict:
        """ Authenticates with google fit and returns a dictionary with
        the most recent valid credentials """
        online_credentials = self.parameter_manager.get_multiple('/google_fit/')
        credentials = GoogleCredentials(**online_credentials, token_expiry=None, user_agent=None)

        http = credentials.authorize(httplib2.Http())
        credentials.refresh(http)

        credentials_dict = json.loads(credentials.to_json())
        self.access_token = credentials_dict.get("access_token")
        self._store_credentials_online(credentials_dict)

        return credentials_dict        
 def get_credentials(self, scope):
     # check
     # run: gcloud beta auth application-default login
     # look to ~/.config/gcloud/application_default_credentials.json
     credentials = GoogleCredentials(
         access_token=None,
         client_id=self.auth['client_id'],
         client_secret=self.auth['client_secret'],
         refresh_token=self.auth['refresh_token'],
         token_expiry=None,
         token_uri=GOOGLE_TOKEN_URI,
         user_agent='Python client library'
     )
     self.logger.debug('Credentials: {}'.format(
         repr(credentials.to_json())
     ))
     return credentials