Read credentials from credential_file if one exists
424095
def credential_file(file=nil)
      unless file.nil?
        dsl_options[:credential_file]=file
        dsl_options.merge!(Ec2.load_keys_from_credential_file(file))
      else
        fetch(:credential_file)
      end
    end
473743
def get_credentials():
    
    home_dir = os.path.expanduser('~')
    credential_dir = os.path.join(home_dir, '.credentials')
    if not os.path.exists(credential_dir):
        os.makedirs(credential_dir)
    credential_path = os.path.join(credential_dir,
                                   'calendar-python-quickstart.json')

    store = Storage(credential_path)
    credentials = store.get()
    if not credentials or credentials.invalid:
        flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
        flow.user_agent = APPLICATION_NAME
        if flags:
            credentials = tools.run_flow(flow, store, flags)
        else: # Needed only for compatibility with Python 2.6
            credentials = tools.run(flow, store)
        print('Storing credentials to ' + credential_path)
    return credentials
721162
def credentials(self):
        
        if self._credentials is None:
            self._credentials = CredentialList(self)
        return self._credentials
1228039
def obtain_credentials(credentials):
    
    if credentials == "-":
        credentials = sys.stdin.readline().strip()
    elif credentials is None:
        credentials = try_getpass(
            "API key (leave empty for anonymous access): ")
    # Ensure that the credentials have a valid form.
    if credentials and not credentials.isspace():
        return Credentials.parse(credentials)
    else:
        return None
1005568
def get_credentials(self):
        
        return ReadOnlyCredentials(
            self.access_token, self.client_id, self.client_secret,
            self.refresh_token
        )
761462
def check_credentials(self, username, password):
        
        return password is not None and self.credentials.get(username, None) == password
59542
def getCredentials(self):
        """"""

        (username, password, public_key, private_key) = self.getCredentialValues()

        if public_key or private_key:
            return UserKeyCredential(username, public_key, private_key)

        if username or password:
            return UserPassCredential(username, password)

        return None
1354962
def credentials_checker(url, username, password):
    """"""
    api = HarvestAPI(url, (username, password))
    try:
        api.whoami()
    except HarvestError:
        return False
    else:
        return True
446065
def _build_credentials_tuple(mech, source, user, passwd, extra):
    
    user = _unicode(user) if user is not None else None
    password = passwd if passwd is None else _unicode(passwd)
    if mech == 'GSSAPI':
        properties = extra.get('authmechanismproperties', {})
        service_name = properties.get('SERVICE_NAME', 'mongodb')
        canonicalize = properties.get('CANONICALIZE_HOST_NAME', False)
        service_realm = properties.get('SERVICE_REALM')
        props = GSSAPIProperties(service_name=service_name,
                                 canonicalize_host_name=canonicalize,
                                 service_realm=service_realm)
        # Source is always $external.
        return MongoCredential(mech, '$external', user, password, props)
    elif mech == 'MONGODB-X509':
        # user can be None.
        return MongoCredential(mech, '$external', user, None, None)
    else:
        if passwd is None:
            raise ConfigurationError("A password is required.")
        return MongoCredential(mech, source, user, password, None)
1024827
def _readCredentials(self):
        
        self._googleJson = os.getenv('GOOGLE_APPLICATION_CREDENTIALS')
        if not self._googleJson:
            raise RuntimeError('GOOGLE_APPLICATION_CREDENTIALS not set.')
        try:
            with open(self._googleJson) as jsonFile:
                self.googleConnectionParams = json.loads(jsonFile.read())
        except:
             raise RuntimeError('GCEProvisioner: Could not parse the Google service account json file %s'
                                % self._googleJson)

        self._projectId = self.googleConnectionParams['project_id']
        self._clientEmail = self.googleConnectionParams['client_email']
        self._credentialsPath = self._googleJson
        self._masterPublicKey = None
        self._gceDriver = self._getDriver()
1325747
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'credential_type' in _dict:
            args['credential_type'] = _dict.get('credential_type')
        if 'client_id' in _dict:
            args['client_id'] = _dict.get('client_id')
        if 'enterprise_id' in _dict:
            args['enterprise_id'] = _dict.get('enterprise_id')
        if 'url' in _dict:
            args['url'] = _dict.get('url')
        if 'username' in _dict:
            args['username'] = _dict.get('username')
        if 'organization_url' in _dict:
            args['organization_url'] = _dict.get('organization_url')
        if 'site_collection.path' in _dict:
            args['site_collection_path'] = _dict.get('site_collection.path')
        if 'client_secret' in _dict:
            args['client_secret'] = _dict.get('client_secret')
        if 'public_key_id' in _dict:
            args['public_key_id'] = _dict.get('public_key_id')
        if 'private_key' in _dict:
            args['private_key'] = _dict.get('private_key')
        if 'passphrase' in _dict:
            args['passphrase'] = _dict.get('passphrase')
        if 'password' in _dict:
            args['password'] = _dict.get('password')
        if 'gateway_id' in _dict:
            args['gateway_id'] = _dict.get('gateway_id')
        if 'source_version' in _dict:
            args['source_version'] = _dict.get('source_version')
        if 'web_application_url' in _dict:
            args['web_application_url'] = _dict.get('web_application_url')
        if 'domain' in _dict:
            args['domain'] = _dict.get('domain')
        if 'endpoint' in _dict:
            args['endpoint'] = _dict.get('endpoint')
        if 'access_key_id' in _dict:
            args['access_key_id'] = _dict.get('access_key_id')
        if 'secret_access_key' in _dict:
            args['secret_access_key'] = _dict.get('secret_access_key')
        return cls(**args)
1044262
def create_credentials(credentials_file=None,
                       service_email=None,
                       service_key=None,
                       scope='https://www.googleapis.com/auth/androidpublisher'):
    
    credentials = None
    if service_email is None and service_key is None:
        print(credentials_file)
        if credentials_file is None:
            # try load file from env
            key = 'PLAY_DELIVER_CREDENTIALS'
            if key in os.environ:
                credentials_file = os.environ[key]

        if credentials_file is None:
            # try to find the file in home
            path = os.path.expanduser('~/.playdeliver/credentials.json')
            if os.path.exists(path):
                credentials_file = path

        if credentials_file is not None:
            credentials = client.GoogleCredentials.from_stream(
                credentials_file)
            credentials = credentials.create_scoped(scope)
        else:
            sys.exit("no credentials")
    else:
        credentials = client.SignedJwtAssertionCredentials(
            service_email, _load_key(service_key), scope=scope)
    return credentials
1267075
def get_storage_credentials(key, read_only=False):
    """"""
    if read_only:
        scopes = ['https://www.googleapis.com/auth/devstorage.read_only']
    else:
        scopes = ['https://www.googleapis.com/auth/devstorage.read_write']

    credentials = service_account.Credentials.from_service_account_info(key)
    
    scoped_credentials = credentials.with_scopes(scopes)
    
    return scoped_credentials
258635
def _load_secret(self, creds_file):
        ''''''
        try:
            with open(creds_file) as fp:
                creds = json.load(fp)
            return creds
        except Exception as e:
            sys.stderr.write("Error loading oauth secret from local file called '{0}'\n".format(creds_file))
            sys.stderr.write("\tThere should be a local OAuth credentials file \n")
            sys.stderr.write("\twhich has contents like this:\n")
            sys.stderr.write("""
                {
                "account_id": "1234567890001",
                "client_id": "30ff0909-0909-33d3-ae88-c9887777a7b7",
                "client_secret": "mzKKjZZyeW5YgsdfBD37c5730g397agU35-Dsgeox6-73giehbt0996nQ"
                }

              """)
            sys.stderr.write("\n")
            raise e
418911
protected synchronized void readCredentialsFile() {
        if (realmFile != null && realmFile.exists() && (realmFile.lastModified() != lastModified)) {
            lastModified = realmFile.lastModified();
            try {
                Map<String, String> credentials = readCredentialsURL(realmFile.toURI().toURL());
                credentialsMap.clear();
                credentialsMap.putAll(credentials);
            } catch (Exception e) {
                log.error("Failed to read {}", realmFile, e);
            }
        }
    }
104356
def ExtractCredentialsFromPathSpec(self, path_spec):
    
    credentials = manager.CredentialsManager.GetCredentials(path_spec)
    for identifier in credentials.CREDENTIALS:
      value = getattr(path_spec, identifier, None)
      if value is None:
        continue

      self.SetCredential(path_spec, identifier, value)
440067
def _get_explicit_environ_credentials():
    """"""
    explicit_file = os.environ.get(environment_vars.CREDENTIALS)

    if explicit_file is not None:
        credentials, project_id = _load_credentials_from_file(
            os.environ[environment_vars.CREDENTIALS])

        return credentials, project_id

    else:
        return None, None