How to use the @aws-amplify/auth.configure function in @aws-amplify/auth

To help you get started, we’ve selected a few @aws-amplify/auth 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 TreeHacks / root / src / index.tsx View on Github external
return Promise.resolve().then(function () {
            return localStorage.getItem(key) || "anonymous";
        });
    }
};
export const custom_header = async () => { 
    try {
        return { Authorization: (await Auth.currentSession()).getIdToken().getJwtToken() }
    }
    catch (e) {
        console.warn(e, "Defaulting to stored JWT in localStorage...");
        // Get JWT from SAML.
        return { Authorization: await asyncLocalStorage.getItem("jwt") } 
    }
}
Auth.configure({
    region: 'us-east-1',
    userPoolId: COGNITO_USER_POOL_ID,
    userPoolWebClientId: COGNITO_CLIENT_ID,
    mandatorySignIn: false
});
API.configure({
    endpoints: [
        {
            name: "treehacks",
            endpoint: ENDPOINT_URL,
            custom_header: custom_header
        }
    ]
});

const authScreenLabels = {
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Auth / Greetings.tsx View on Github external
renderSignOutButton() {
		const { federated = {} } = this.props;
		const {
			google_client_id,
			facebook_app_id,
			amazon_client_id,
			auth0,
		} = federated;
		// @ts-ignore
		const config = Auth.configure();
		const { oauth = {} } = config;
		// @ts-ignore
		const googleClientId = google_client_id || config.googleClientId;
		// @ts-ignore
		const facebookAppId = facebook_app_id || config.facebookClientId;
		// @ts-ignore
		const amazonClientId = amazon_client_id || config.amazonClientId;
		// @ts-ignore
		const auth0_config = auth0 || oauth.auth0;

		let SignOutComponent = SignOut;
		// @ts-ignore
		if (googleClientId) SignOutComponent = withGoogle(SignOut);
		// @ts-ignore
		if (facebookAppId) SignOutComponent = withFacebook(SignOut);
		// @ts-ignore
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Auth / Provider / withAuth0.tsx View on Github external
initialize() {
			// @ts-ignore
			const { oauth = {} } = Auth.configure();
			// @ts-ignore
			const config = this.props.auth0 || options || oauth.auth0;
			const { onError, onStateChange, authState } = this.props;
			if (!config) {
				logger.debug('Auth0 is not configured');
				return;
			}

			logger.debug('withAuth0 configuration', config);

			if (!this._auth0) {
				this._auth0 = new window['auth0'].WebAuth(config);
				window.auth0_client = this._auth0;
			}

			if (authState !== 'signedIn') {
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Auth / FederatedSignIn.tsx View on Github external
render() {
		const { authState } = this.props;
		if (!['signIn', 'signedOut', 'signedUp'].includes(authState)) {
			return null;
		}

		const federated = this.props.federated || {};
		if (!Auth || typeof Auth.configure !== 'function') {
			throw new Error(
				'No Auth module found, please ensure @aws-amplify/auth is imported'
			);
		}

		// @ts-ignore
		const { oauth = {} } = Auth.configure();
		// backward compatibility
		if (oauth['domain']) {
			federated.oauth_config = Object.assign({}, federated.oauth_config, oauth);
			// @ts-ignore
		} else if (oauth.awsCognito) {
			// @ts-ignore
			federated.oauth_config = Object.assign(
				{},
				federated.oauth_config,
				// @ts-ignore
				oauth.awsCognito
			);
		}

		// @ts-ignore
		if (oauth.auth0) {
github webiny / webiny-js / packages / app-plugin-security-cognito / src / index.js View on Github external
export default config => {
    // Configure Amplify Auth
    Auth.configure(config);

    return {
        name: "security-authentication-provider-cognito",
        type: "security-authentication-provider",
        securityProviderHook({ onIdToken }) {
            const renderAuthentication = () => {
                return ;
            };

            const logout = async () => {
                await Auth.signOut();
            };

            const getIdToken = async () => {
                const cognitoUser = await Auth.currentSession();
                return cognitoUser ? cognitoUser.idToken.jwtToken : null;
github 8thwall / web / gettingstarted / xrsumerian / src / app.js View on Github external
import Auth from '@aws-amplify/auth';
import Amplify from 'aws-amplify';
import awsconfig from './aws-exports';
import aws_exports from './aws-exports';

import { XR as AwsXR } from 'aws-amplify';
import scene1Config from './sumerian-exports';

Amplify.configure(aws_exports);

Auth.configure(awsconfig);

AwsXR.configure({
  SumerianProvider: {
    region: 'us-west-2', // Sumerian region
    scenes: {
      "scene1": { // Friendly scene name
        sceneConfig: scene1Config // Scene configuration from Sumerian publish
      }
    },
  }
});

let xrready = false

const isXrReady = () => {
  return xrready
github allenmichael / petunia / petunia-mobile / App.js View on Github external
import React from 'react';
import { Platform, StatusBar, StyleSheet, View } from 'react-native';
import { AppLoading, Asset, Font, Icon } from 'expo';
import AppNavigator from './navigation/AppNavigator';
import Auth from '@aws-amplify/auth';
import awsconfig from './aws-exports';
import { withAuthenticator } from 'aws-amplify-react-native';
import { ActionSheetProvider,connectActionSheet} from '@expo/react-native-action-sheet';

Auth.configure(awsconfig);

class App extends React.Component {
  state = {
    isLoadingComplete: false,
  };

  render() {
    if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {
      return (
        
      );
    } else {
github aws-amplify / amplify-js / packages / amplify-ui-components / src / components / amplify-examples / amplify-examples.tsx View on Github external
import { Component, State, h } from '@stencil/core';
import { AuthenticatorExample } from './authenticator-example';
import example4 from './example4';
import sceneExample from './scene-example';
import Auth from '@aws-amplify/auth';
import XR from '@aws-amplify/xr';
import awsexports from './src/aws-exports';

Auth.configure(awsexports);
XR.configure(awsexports);

const examples = [AuthenticatorExample, example4, sceneExample];

(window as any).LOG_LEVEL = 'DEBUG';

const Tabs = ({ active, set }) => (
  <ul>
    {examples.map(({ title }, index) =&gt; (
      <li class="{active">
        <a> set(index)} href="javascript:void(0);"&gt;
          {title}
        </a>
      </li>
    ))}
  </ul>
github aws-amplify / amplify-js / packages / amplify-ui-components / src / components / amplify-examples / scene-example.tsx View on Github external
import { h } from '@stencil/core';
import Auth from '@aws-amplify/auth';
import XR from '@aws-amplify/xr';
import awsexports from './src/aws-exports';

Auth.configure(awsexports);
XR.configure(awsexports);

const sceneExample = () =&gt; ;

export default {
  title: 'Scene example',
  Content: sceneExample,
};