code: def GetCredentials(package_name, scopes, client_id, client_secret, user_agent,
                     credentials_filename=None,
                     api_key=None,  # pylint: disable=unused-argument
                     client=None,  # pylint: disable=unused-argument
                     oauth2client_args=None,
                     **kwds):
      
      scopes = util.NormalizeScopes(scopes)
      client_info = {
          'client_id': client_id,
          'client_secret': client_secret,
          'scope': ' '.join(sorted(scopes)),
          'user_agent': user_agent or '%s-generated/0.1' % package_name,
      }
      for method in _CREDENTIALS_METHODS:
          credentials = method(client_info, **kwds)
          if credentials is not None:
              return credentials
      credentials_filename = credentials_filename or os.path.expanduser(
          '~/.apitools.token')
      credentials = CredentialsFromFile(credentials_filename, client_info,
                                        oauth2client_args=oauth2client_args)
      if credentials is not None:
          return credentials
      raise exceptions.CredentialsError('Could not create valid credentials')
docs: Attempt to get credentials, using an oauth dance as the last resort.