/*
(non-Javadoc)

@see
org.duracloud.mill.credentials.CredentialRepo#getStorageProviderCredentials
(java.lang.String, java.lang.String)
977845
@Override
    public StorageProviderCredentials getStorageProviderCredentials(String subdomain, String storeId)
        throws AccountCredentialsNotFoundException, StorageProviderCredentialsNotFoundException {

        AccountInfo account = accountRepo.findBySubdomain(subdomain);
        Long id = Long.valueOf(storeId);
        if (account == null) {
            throw new AccountCredentialsNotFoundException("no account found for subdomain " + subdomain);
        } else {
            StorageProviderAccount provider = account.getPrimaryStorageProviderAccount();
            if (provider.getId().equals(id)) {
                return createStorageProviderCredentials(storeId, provider, true);
            } else {
                for (StorageProviderAccount sp : account.getSecondaryStorageProviderAccounts()) {
                    if (sp.getId().equals(id)) {
                        return createStorageProviderCredentials(storeId, sp, false);
                    }
                }
            }
        }

        throw new StorageProviderCredentialsNotFoundException(
            "No storage provider on subdomain " + subdomain
            + " with storeId " + storeId + " found.");
    }
187365
protected IPromise<BasicAuthenticationResult> getCredentials(String user, String pw, String jwt) {
        Promise p = new Promise();
        if ( SESSIONID_SPECIAL_STRING.equals(pw) ) {
            sessionStorage.getUserFromSessionId(user).then( (r,e) -> {
                if ( r != null ) {
                    sessionStorage.getUser(r).then( (rec,err) -> {
                        if ( rec != null )
                            getCredentials(rec.getKey(),rec.getString("pwd"), null ).then(p);
                        else
                            p.reject("unknown user");
                    });
                } else {
                    p.reject("authentication failed");
                }
            });
        } else {
            sessionStorage.getUser(user).then((rec, err) -> {
                if (rec == null) {
                    p.reject("wrong user or password");
                } else {
                    if (pw.equals(rec.getString("pwd"))) {
                        if (!rec.getBool("verified")) {
                            // e.g. email verification etc.
                            p.reject("account not verified");
                        } else
                            p.resolve(new BasicAuthenticationResult().userName(rec.getKey()));
                    }
                }
            });
        }
        return p;
    }
388823
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')
99411
private void getCredentials(final String code) {
        new AsyncTask<Void, Void, Boolean>() {
            @Override
            protected Boolean doInBackground(Void... params) {
                try {
                    mBootstrapper.getUserCredentials(code);
                    return true;

                } catch (IOException ex) {
                    LOGGER.error("Error getting oauth credentials", ex);
                    setResult(RESULT_CANCELED);
                    finish();

                } catch (CStorageException ex) {
                    LOGGER.error("Error getting oauth credentials", ex);
                    setResult(RESULT_CANCELED);
                    finish();
                }
                // Failure
                return false;
            }

            @Override
            protected void onPostExecute(Boolean result) {
                if(result) {
                    setResult(RESULT_OK);
                } else {
                    setResult(RESULT_CANCELED);
                }
                finish();
            }
        }.execute();
    }
555096
public Credentials getScopedCredentials() {
    Credentials credentialsToReturn = credentials;
    if (credentials instanceof GoogleCredentials
        && ((GoogleCredentials) credentials).createScopedRequired()) {
      credentialsToReturn = ((GoogleCredentials) credentials).createScoped(getScopes());
    }
    return credentialsToReturn;
  }
1080228
public CredentialsConfig getResolvingCredentialsConfig() {
        if (resolverCredentialsConfig != null && resolverCredentialsConfig.isCredentialsProvided()) {
            return getResolverCredentialsConfig();
        }
        if (deployerCredentialsConfig != null) {
            return getDeployerCredentialsConfig();
        }

        return CredentialsConfig.EMPTY_CREDENTIALS_CONFIG;
    }
1252545
public ICredentialRepository getCredentialRepository()
    {
        if (this.credentialRepositorySearched) return this.credentialRepository;

        this.credentialRepositorySearched = true;

        ServiceLoader<ICredentialRepository> loader =
                ServiceLoader.load(ICredentialRepository.class);

        //noinspection LoopStatementThatDoesntLoop
        for (ICredentialRepository repository : loader)
        {
            this.credentialRepository = repository;
            break;
        }

        return this.credentialRepository;
    }
905761
public static MozuUrl storeCredentialsUrl()
	{
		UrlFormatter formatter = new UrlFormatter("/api/platform/extensions/credentialStore/");
		return new MozuUrl(formatter.getResourceUrl(), MozuUrl.UrlLocation.TENANT_POD) ;
	}
1028363
def getCredentials():
    ''' 
        
    '''
    logger = logging.getLogger("osrframework.utils")
    # Dictionary of lists:
    #     {'Twitter': {cred1, cred2, ...}}
    creds = {} 
    try:
        credsTuples = c_creds.returnListOfCreds()

        for cTuple in credsTuples:
            plat, user, password = cTuple

            c = Credential(user, password)

            if plat not in creds.keys():
                creds[plat] = [c]
            else:
                creds[plat] = creds[plat].append(c)
        logger.info(str(len(credsTuples)) + " credentials have been loaded.")    
        return creds
    except Exception, e:
        logger.error("WARNING. Something happened when loading credentials.")
        logger.error(str(e))        
        logger.debug("No credentials were loaded.")    
    return {}
1145901
@Override
    public synchronized void refreshCredentials() {
        GetSessionTokenResult sessionTokenResult = securityTokenService
                .getSessionToken(new GetSessionTokenRequest().withDurationSeconds(sessionDurationSeconds));
        sessionCredentials = sessionTokenResult.getCredentials();
    }
603323
private static CredentialProvider getCredentialProvider(TextDevice textDevice) throws IOException {
        String providerPath = textDevice.readLine("Please enter the full path to the credential provider:");

        if (providerPath != null) {
            Configuration conf = new Configuration(false);
            conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, providerPath);
            return CredentialProviderFactory.getProviders(conf).get(0);
        }

        return null;
    }
829049
public ArrayList<Long> api_credential_GET(Long applicationId, OvhCredentialStateEnum status) throws IOException {
		String qPath = "/me/api/credential";
		StringBuilder sb = path(qPath);
		query(sb, "applicationId", applicationId);
		query(sb, "status", status);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, t2);
	}
1104511
public OvhApplication api_credential_credentialId_application_GET(Long credentialId) throws IOException {
		String qPath = "/me/api/credential/{credentialId}/application";
		StringBuilder sb = path(qPath, credentialId);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhApplication.class);
	}
831231
public static Map<String, IAMSecurityCredential> getIAMSecurityCredentials() {
        Map<String, IAMSecurityCredential> credentialsInfoMap = new HashMap<String, IAMSecurityCredential>();

        List<String> credentials = getItems(EC2_METADATA_ROOT
                + "/iam/security-credentials");

        if (null != credentials) {
            for (String credential : credentials) {
                String json = getData(EC2_METADATA_ROOT
                        + "/iam/security-credentials/" + credential);
                try {
                    IAMSecurityCredential credentialInfo = mapper
                            .readValue(json, IAMSecurityCredential.class);
                    credentialsInfoMap.put(credential, credentialInfo);
                } catch (Exception e) {
                    log.warn("Unable to process the credential (" + credential
                            + "). " + e.getMessage(), e);
                }
            }
        }
        return credentialsInfoMap;
    }
683724
public Credential getCredential() {
    if (hasStoredCredential()) {
      HttpTransport httpTransport;
      try {
        httpTransport = GoogleNetHttpTransport.newTrustedTransport();
      } catch (IOException | GeneralSecurityException e) {
        throw new RuntimeException("Could not create HTTPS transport for use in credential creation", e);
      }

      return new GoogleCredential.Builder()
      .setJsonFactory(JacksonFactory.getDefaultInstance())
      .setTransport(httpTransport)
      .setClientSecrets(getClientId(), getClientSecret())
      .build()
      .setRefreshToken(getRefreshToken());
    }
    return CredentialFactory.getApplicationDefaultCredential();
  }
1005568
def get_credentials(self):
        
        return ReadOnlyCredentials(
            self.access_token, self.client_id, self.client_secret,
            self.refresh_token
        )
986652
@Override
    protected final Principal getPrincipal(final Credentials credentials) {
        try {
            Optional<Principal> principalOptional = cache.get(credentials.getApiKey(), new Callable<Optional<Principal>>() {
                public Optional<Principal> call() throws Exception {
                    return Optional.fromNullable(loadPrincipal(credentials));
                }
            });
            return principalOptional.orNull();
        } catch (ExecutionException e) {
            LOG.warn("Exception when loading the cache for credentials with API key " + credentials.getApiKey());
            return null;
        }
    }