Skip to content

Commit 1ae6c30

Browse files
Add auth callback HTML for token handling
1 parent f73a270 commit 1ae6c30

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

callback.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Auth Callback</title>
6+
</head>
7+
<body>
8+
<script>
9+
// Supabase will redirect here with the access_token/id_token in the URL hash
10+
// Example: https://your-webpage.com/callback#access_token=...&type=...&expires_in=...
11+
12+
const hash = window.location.hash.substr(1); // remove #
13+
const params = new URLSearchParams(hash);
14+
const accessToken = params.get('access_token');
15+
const idToken = params.get('id_token');
16+
17+
if (accessToken) {
18+
// Redirect to your app using deep link and pass the token
19+
window.location.href = myapp://login-callback?access_token=${accessToken}&id_token=${idToken};
20+
} else {
21+
document.body.innerHTML = "Login failed or cancelled.";
22+
}
23+
</script>
24+
</body>
25+
</html>

0 commit comments

Comments
 (0)