Last active
February 19, 2022 17:14
-
-
Save EvanBurbidge/b51c4bf0eebf089b36f06b96f05a430d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | |
); | |
} |
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
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.