src/Credentials/CredentialProvider.php
public static function ini($profile = null, $filename = null)
    {
        $filename = $filename ?: (self::getHomeDir() . '/.aws/credentials');
        $profile = $profile ?: (getenv(self::ENV_PROFILE) ?: 'default');

        return function () use ($profile, $filename) {
            if (!is_readable($filename)) {
                return self::reject("Cannot read credentials from $filename");
            }
            $data = \Aws\parse_ini_file($filename, true, INI_SCANNER_RAW);
            if ($data === false) {
                return self::reject("Invalid credentials file: $filename");
            }
            if (!isset($data[$profile])) {
                return self::reject("'$profile' not found in credentials file");
            }
            if (!isset($data[$profile]['aws_access_key_id'])
                || !isset($data[$profile]['aws_secret_access_key'])
            ) {
                return self::reject("No credentials present in INI profile "
                    . "'$profile' ($filename)");
            }

            if (empty($data[$profile]['aws_session_token'])) {
                $data[$profile]['aws_session_token']
                    = isset($data[$profile]['aws_security_token'])
                        ? $data[$profile]['aws_security_token']
                        : null;
            }

            return Promise\promise_for(
                new Credentials(
                    $data[$profile]['aws_access_key_id'],
                    $data[$profile]['aws_secret_access_key'],
                    $data[$profile]['aws_session_token']
                )
            );
        };
    }
public static function ini($profile = null, $filename = null)
    {
        $filename = $filename ?: (self::getHomeDir() . '/.aws/credentials');
        $profile = $profile ?: (getenv(self::ENV_PROFILE) ?: 'default');

        return function () use ($profile, $filename) {
            if (!is_readable($filename)) {
                return self::reject("Cannot read credentials from $filename");
            }
            $data = \Aws\parse_ini_file($filename, true, INI_SCANNER_RAW);
            if ($data === false) {
                return self::reject("Invalid credentials file: $filename");
            }
            if (!isset($data[$profile])) {
                return self::reject("'$profile' not found in credentials file");
            }
            if (!isset($data[$profile]['aws_access_key_id'])
                || !isset($data[$profile]['aws_secret_access_key'])
            ) {
                return self::reject("No credentials present in INI profile "
                    . "'$profile' ($filename)");
            }

            if (empty($data[$profile]['aws_session_token'])) {
                $data[$profile]['aws_session_token']
                    = isset($data[$profile]['aws_security_token'])
                        ? $data[$profile]['aws_security_token']
                        : null;
            }

            return Promise\promise_for(
                new Credentials(
                    $data[$profile]['aws_access_key_id'],
                    $data[$profile]['aws_secret_access_key'],
                    $data[$profile]['aws_session_token']
                )
            );
        };
    }
public static function ini ( $ profile = null , $ filename = null ) { $ filename = $ filename ? : ( self :: getHomeDir ( ) . '/.aws/credentials' ) ; $ profile = $ profile ? : ( getenv ( self :: ENV_PROFILE ) ? : 'default' ) ; return function ( ) use ( $ profile , $ filename ) { if ( ! is_readable ( $ filename ) ) { return self :: reject ( "Cannot read credentials from $filename" ) ; } $ data = \ Aws \ parse_ini_file ( $ filename , true , INI_SCANNER_RAW ) ; if ( $ data === false ) { return self :: reject ( "Invalid credentials file: $filename" ) ; } if ( ! isset ( $ data [ $ profile ] ) ) { return self :: reject ( "'$profile' not found in credentials file" ) ; } if ( ! isset ( $ data [ $ profile ] [ 'aws_access_key_id' ] ) || ! isset ( $ data [ $ profile ] [ 'aws_secret_access_key' ] ) ) { return self :: reject ( "No credentials present in INI profile " . "'$profile' ($filename)" ) ; } if ( empty ( $ data [ $ profile ] [ 'aws_session_token' ] ) ) { $ data [ $ profile ] [ 'aws_session_token' ] = isset ( $ data [ $ profile ] [ 'aws_security_token' ] ) ? $ data [ $ profile ] [ 'aws_security_token' ] : null ; } return Promise \ promise_for ( new Credentials ( $ data [ $ profile ] [ 'aws_access_key_id' ] , $ data [ $ profile ] [ 'aws_secret_access_key' ] , $ data [ $ profile ] [ 'aws_session_token' ] ) ) ; } ; }
Credentials provider that creates credentials using an ini file stored
in the current user's home directory.

@param string|null $profile  Profile to use. If not specified will use
the "default" profile in "~/.aws/credentials".
@param string|null $filename If provided, uses a custom filename rather
than looking in the home directory.

@return callable
Credentials provider that creates credentials using an ini file stored in the current user s home directory .