How to use the @aws-amplify/core.Credentials.get function in @aws-amplify/core

To help you get started, we’ve selected a few @aws-amplify/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws-amplify / amplify-js / packages / api / src / RestClient.ts View on Github external
// Do not sign the request if client has added 'Authorization' header,
        // which means custom authorizer.
        if (typeof params.headers['Authorization'] !== 'undefined') {
            params.headers = Object.keys(params.headers).reduce((acc, k) => {
                if (params.headers[k]) {
                    acc[k] = params.headers[k];
                }
                return acc;
                // tslint:disable-next-line:align
            }, {});
            return this._request(params, isAllResponse);

        }
        
        // Signing the request in case there credentials are available
        return Credentials.get()
            .then(
                credentials => this._signed({ ...params }, credentials, isAllResponse),
                err => {
                    logger.debug('No credentials available, the request will be unsigned');
                    return this._request(params, isAllResponse);
                }
                );
    }
github aws-amplify / amplify-js / packages / api / src / RestClient.ts View on Github external
// Do not sign the request if client has added 'Authorization' header,
		// which means custom authorizer.
		if (typeof params.headers['Authorization'] !== 'undefined') {
			params.headers = Object.keys(params.headers).reduce((acc, k) => {
				if (params.headers[k]) {
					acc[k] = params.headers[k];
				}
				return acc;
				// tslint:disable-next-line:align
			}, {});
			return this._request(params, isAllResponse);
		}

		// Signing the request in case there credentials are available
		return Credentials.get().then(
			credentials => this._signed({ ...params }, credentials, isAllResponse),
			err => {
				logger.debug('No credentials available, the request will be unsigned');
				return this._request(params, isAllResponse);
			}
		);
	}
github aws-amplify / amplify-js / packages / storage / src / Providers / AWSS3Provider.ts View on Github external
_ensureCredentials() {

        return Credentials.get()
            .then(credentials => {
                if (!credentials) return false;
                const cred = Credentials.shear(credentials);
                logger.debug('set credentials for storage', cred);
                this._config.credentials = cred;

                return true;
            })
            .catch(err => {
                logger.warn('ensure credentials error', err);
                return false;
            });
    }
github aws-amplify / amplify-js / packages / api-graphql / src / GraphQLAPI.ts View on Github external
_ensureCredentials() {
		return Credentials.get()
			.then(credentials => {
				if (!credentials) return false;
				const cred = Credentials.shear(credentials);
				logger.debug('set credentials for api', cred);

				return true;
			})
			.catch(err => {
				logger.warn('ensure credentials error', err);
				return false;
			});
	}
}
github aws-amplify / amplify-js / packages / api / src / API.ts View on Github external
_ensureCredentials() {
		return Credentials.get()
			.then(credentials => {
				if (!credentials) return false;
				const cred = Credentials.shear(credentials);
				logger.debug('set credentials for api', cred);

				return true;
			})
			.catch(err => {
				logger.warn('ensure credentials error', err);
				return false;
			});
	}
}
github aws-amplify / amplify-js / packages / api / src / API.ts View on Github external
_ensureCredentials() {
        return Credentials.get()
            .then(credentials => {
                if (!credentials) return false;
                const cred = Credentials.shear(credentials);
                logger.debug('set credentials for api', cred);

                return true;
            })
            .catch(err => {
                logger.warn('ensure credentials error', err);
                return false;
            });
    }
}
github aws-amplify / amplify-js / packages / analytics / src / Providers / AWSPinpointProvider.ts View on Github external
private async _getCredentials() {
		try {
			const credentials = await Credentials.get();
			if (!credentials) return null;

			logger.debug('set credentials for analytics', credentials);
			return Credentials.shear(credentials);
		} catch (err) {
			logger.debug('ensure credentials error', err);
			return null;
		}
	}
}