Update Spotify Auth implementation
This commit is contained in:
@@ -32,22 +32,24 @@ export default function LoginScreen({ navigation }) {
|
||||
};
|
||||
|
||||
const handleSpotifyAuth = async () => {
|
||||
Alert.alert('Teste', 'O botão do Spotify foi clicado!');
|
||||
try {
|
||||
const redirectUri = makeRedirectUri();
|
||||
const { data, error } = await supabase.auth.signInWithOAuth({
|
||||
provider: 'spotify',
|
||||
options: {
|
||||
redirectTo: makeRedirectUri()
|
||||
}
|
||||
redirectTo: redirectUri,
|
||||
},
|
||||
});
|
||||
|
||||
if (error) {
|
||||
Alert.alert('Erro no login Spotify', error.message);
|
||||
return;
|
||||
}
|
||||
if (error) throw error;
|
||||
|
||||
if (data?.url) {
|
||||
await WebBrowser.openAuthSessionAsync(data.url, makeRedirectUri());
|
||||
const res = await WebBrowser.openAuthSessionAsync(data.url, redirectUri);
|
||||
if (res.type === 'success') {
|
||||
const { url } = res;
|
||||
// Ensure Supabase catches the session from the returned URL
|
||||
await supabase.auth.getSessionFromUrl(url);
|
||||
}
|
||||
}
|
||||
} catch (err: any) {
|
||||
Alert.alert('Erro', err?.message || 'Ocorreu um erro no Spotify Auth.');
|
||||
|
||||
@@ -43,22 +43,24 @@ export default function RegisterScreen({ navigation }) {
|
||||
};
|
||||
|
||||
const handleSpotifyAuth = async () => {
|
||||
Alert.alert('Teste', 'O botão do Spotify foi clicado!');
|
||||
try {
|
||||
const redirectUri = makeRedirectUri();
|
||||
const { data, error } = await supabase.auth.signInWithOAuth({
|
||||
provider: 'spotify',
|
||||
options: {
|
||||
redirectTo: makeRedirectUri()
|
||||
}
|
||||
redirectTo: redirectUri,
|
||||
},
|
||||
});
|
||||
|
||||
if (error) {
|
||||
Alert.alert('Erro no login Spotify', error.message);
|
||||
return;
|
||||
}
|
||||
if (error) throw error;
|
||||
|
||||
if (data?.url) {
|
||||
await WebBrowser.openAuthSessionAsync(data.url, makeRedirectUri());
|
||||
const res = await WebBrowser.openAuthSessionAsync(data.url, redirectUri);
|
||||
if (res.type === 'success') {
|
||||
const { url } = res;
|
||||
// Ensure Supabase catches the session from the returned URL
|
||||
await supabase.auth.getSessionFromUrl(url);
|
||||
}
|
||||
}
|
||||
} catch (err: any) {
|
||||
Alert.alert('Erro', err?.message || 'Ocorreu um erro no Spotify Auth.');
|
||||
|
||||
Reference in New Issue
Block a user