Skip to content

Instantly share code, notes, and snippets.

@KevinDanikowski
Created July 27, 2020 18:55
Show Gist options
  • Save KevinDanikowski/58a24be0e3067e545c4d6a85dcc94194 to your computer and use it in GitHub Desktop.
Save KevinDanikowski/58a24be0e3067e545c4d6a85dcc94194 to your computer and use it in GitHub Desktop.
import getConfig from 'next/config'
import { UserProvider, initUser } from '../lib/UserContext'
import Amplify from '@aws-amplify/core'
import Auth from '@aws-amplify/auth'
const {
publicRuntimeConfig: { aws, appEnv },
} = getConfig()
Amplify.configure({
Auth: {
region: aws.region,
userPoolId: aws.userPoolId,
userPoolWebClientId: aws.userPoolWebClientId,
},
})
Auth.configure({
oauth: {
domain: aws.idpDomain,
// must have these checked on the cognito AWS console, profile is necessary to get user data
scope: ['email', 'openid', 'profile'],
redirectSignIn: aws.redirectSignIn,
redirectSignOut: aws.redirectSignOut,
responseType: 'token',
},
})
class MyApp extends App {
...
render() {
const { Component, pageProps } = this.props
return (
<UserProvider value={initUser}>
<Component {...pageProps} />
</UserProvider>
)
}
}
export default withApollo(MyApp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment