How to use the @aws-amplify/core.Auth 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 / aws-amplify-angular / src / __tests__ / providers / amplify.service.spec.ts View on Github external
it('...should be returning Amplify.Auth', inject([AmplifyService], (service: AmplifyService) => {
      const myAuth = service.auth();
      expect(myAuth).toEqual(Amplify.Auth);
    }));
github aws-amplify / amplify-js / packages / api / src / API.ts View on Github external
break;
            case 'AWS_IAM':
                const credentialsOK = await this._ensureCredentials();
                if (!credentialsOK) { throw new Error('No credentials'); }
                break;
            case 'OPENID_CONNECT':
                const federatedInfo = await Cache.getItem('federatedInfo');

                if (!federatedInfo || !federatedInfo.token) { throw new Error('No federated jwt'); }
                headers = {
                    Authorization: federatedInfo.token
                };
                break;
            case 'AMAZON_COGNITO_USER_POOLS':
                if (Amplify.Auth && typeof Amplify.Auth.currentSession === 'function') {
                    const session = await Amplify.Auth.currentSession();
                    headers = {
                        Authorization: session.getAccessToken().getJwtToken()
                    };
                } else {
                    throw new Error('No Auth module registered in Amplify');
                }
                break;
            default:
                headers = {
                    Authorization: null,
                };
                break;
        }

        return headers;
    }
github aws-amplify / amplify-js / packages / api / src / API.ts View on Github external
};
                break;
            case 'AWS_IAM':
                const credentialsOK = await this._ensureCredentials();
                if (!credentialsOK) { throw new Error('No credentials'); }
                break;
            case 'OPENID_CONNECT':
                const federatedInfo = await Cache.getItem('federatedInfo');

                if (!federatedInfo || !federatedInfo.token) { throw new Error('No federated jwt'); }
                headers = {
                    Authorization: federatedInfo.token
                };
                break;
            case 'AMAZON_COGNITO_USER_POOLS':
                if (Amplify.Auth && typeof Amplify.Auth.currentSession === 'function') {
                    const session = await Amplify.Auth.currentSession();
                    headers = {
                        Authorization: session.getAccessToken().getJwtToken()
                    };
                } else {
                    throw new Error('No Auth module registered in Amplify');
                }
                break;
            default:
                headers = {
                    Authorization: null,
                };
                break;
        }

        return headers;
github aws-amplify / amplify-js / packages / aws-amplify-angular / src / providers / auth.decorator.ts View on Github external
Auth.signOut = (): Promise => {
		return _signOut
			.call(Amplify.Auth)
			.then(data => {
				logger.debug('signOut success');
				authState.next({ state: 'signedOut', user: null });
				return data;
			})
			.catch(err => {
				logger.debug('signOut error', err);
				throw err;
			});
	};
}
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Categories.js View on Github external
import Amplify from '@aws-amplify/core';

const Auth = Amplify.Auth;
const API = Amplify.API;
const Analytics = Amplify.Analytics;
const Storage = Amplify.Storage;
const PubSub = Amplify.PubSub;
const Interactions = Amplify.Interactions;

export { Auth, API, Analytics, Storage, PubSub, Interactions };
github aws-amplify / amplify-js / packages / aws-amplify / src / index.ts View on Github external
import XR, { XRClass } from '@aws-amplify/xr';
import Predictions from '@aws-amplify/predictions';

import Amplify, {
	ConsoleLogger as Logger,
	Hub,
	JS,
	ClientDevice,
	Signer,
	I18n,
	ServiceWorker,
} from '@aws-amplify/core';

export default Amplify;

Amplify.Auth = Auth;
Amplify.Analytics = Analytics;
Amplify.API = API;
Amplify.Storage = Storage;
Amplify.I18n = I18n;
Amplify.Cache = Cache;
Amplify.PubSub = PubSub;
Amplify.Logger = Logger;
Amplify.ServiceWorker = ServiceWorker;
Amplify.Interactions = Interactions;
Amplify.UI = UI;
Amplify.XR = XR;
Amplify.Predictions = Predictions;

export {
	Auth,
	Analytics,