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