Skip to content

Instantly share code, notes, and snippets.

@EvanBurbidge
Last active February 19, 2022 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EvanBurbidge/b51c4bf0eebf089b36f06b96f05a430d to your computer and use it in GitHub Desktop.
Save EvanBurbidge/b51c4bf0eebf089b36f06b96f05a430d to your computer and use it in GitHub Desktop.
import * as AuthSession from 'expo-auth-session';
import jwtDecode from 'jwt-decode';
import { Alert, Platform, StyleSheet, Image } from 'react-native';
// you need to swap out these details with your auth0 credientals
const auth0ClientId = "";
const authorizationEndpoint = "https://yourtennant.auth0.com/authorize";
const useProxy = Platform.select({ web: false, default: true });
const redirectUri = AuthSession.makeRedirectUri({ useProxy });
console.log(redirectUri) // <-- you will need to add this to your auth0 callbacks / logout configs
export default function Login() {
const [request, result, promptAsync] = AuthSession.useAuthRequest(
{
redirectUri,
clientId: auth0ClientId,
// id_token will return a JWT token
responseType: 'id_token',
// retrieve the user's profile
scopes: ['openid', 'profile', 'email'],
extraParams: {
// ideally, this will be a random value
nonce: 'nonce',
},
},
{ authorizationEndpoint }
);
return (
<Layout style={styles.container} level="1">
<Button
style={styles.button}
onPress={() => promptAsync({ useProxy })} // <-- will open the universal login
>
Login
</Button>
</Layout>
);
}
@EvanBurbidge
Copy link
Author

Hey @Kischy could you show an example of what result is returning? These scopes are mainly from auth0 so they should work across the board.

@Kischy
Copy link

Kischy commented Feb 19, 2022

I think I found the problem. Thanks anyways 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment