Fedi.CrowdedGames.Group/JS/mail.js
2025-04-22 15:49:23 -07:00

16 lines
774 B
JavaScript

import * as ActivityPub from "./ActivityPub.js";
let LoginButton = document.getElementsByClassName("Login")[0];
LoginButton.onclick = (event) => {
HandleLogin();
}
async function HandleLogin() {
let Origin = window.location.origin + "/HTML/mail";
let InstanceData = await fetch("https://wetdry.world/api/v1/apps?client_name=Channel Viewer&redirect_uris=" + Origin + "&scopes=" + ActivityPub.Scopes, {method: "POST"})
.then((response) => response.json());
let InstanceInfo = await fetch("https://wetdry.world/api/v1/instance", {method: "GET"})
.then((response) => response.json());
document.location.href = "https://wetdry.world/oauth/authorize?client_id=" + InstanceData.client_id + "&redirect_uri=" + Origin + "&response_type=code&scope=" + ActivityPub.Scopes;
}