- Add state-based lock (isTestRunning) to prevent duplicate API calls - Update error handling in edge function for body consumption - Add OAuth2 token generation helper tool (get-google-token-local.html) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
153 lines
5.2 KiB
HTML
153 lines
5.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Test Google OAuth Config</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
max-width: 800px;
|
|
margin: 50px auto;
|
|
padding: 20px;
|
|
background: #f5f5f5;
|
|
}
|
|
.container {
|
|
background: white;
|
|
padding: 30px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|
}
|
|
textarea {
|
|
width: 100%;
|
|
min-height: 120px;
|
|
padding: 10px;
|
|
border: 2px solid #ddd;
|
|
border-radius: 4px;
|
|
font-family: monospace;
|
|
box-sizing: border-box;
|
|
}
|
|
button {
|
|
background: #4285f4;
|
|
color: white;
|
|
padding: 12px 24px;
|
|
border: none;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-size: 16px;
|
|
margin-top: 15px;
|
|
}
|
|
button:hover {
|
|
background: #3367d6;
|
|
}
|
|
#result {
|
|
margin-top: 20px;
|
|
padding: 15px;
|
|
border-radius: 4px;
|
|
display: none;
|
|
}
|
|
.success {
|
|
background: #e8f5e9;
|
|
border: 2px solid #4caf50;
|
|
}
|
|
.error {
|
|
background: #ffebee;
|
|
border: 2px solid #f44336;
|
|
}
|
|
pre {
|
|
white-space: pre-wrap;
|
|
word-wrap: break-word;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>Test Google OAuth Config</h1>
|
|
<p>Paste your OAuth config JSON below to test if the refresh token is valid:</p>
|
|
|
|
<textarea id="oauthConfig" placeholder='{
|
|
"client_id": "...",
|
|
"client_secret": "...",
|
|
"refresh_token": "..."
|
|
}'></textarea>
|
|
|
|
<button onclick="testConfig()">Test Configuration</button>
|
|
|
|
<div id="result"></div>
|
|
</div>
|
|
|
|
<script>
|
|
async function testConfig() {
|
|
const configTextarea = document.getElementById('oauthConfig');
|
|
const resultDiv = document.getElementById('result');
|
|
resultDiv.style.display = 'none';
|
|
|
|
let config;
|
|
try {
|
|
config = JSON.parse(configTextarea.value);
|
|
} catch (e) {
|
|
resultDiv.className = 'error';
|
|
resultDiv.innerHTML = '<strong>Error:</strong> Invalid JSON format';
|
|
resultDiv.style.display = 'block';
|
|
return;
|
|
}
|
|
|
|
if (!config.client_id || !config.client_secret || !config.refresh_token) {
|
|
resultDiv.className = 'error';
|
|
resultDiv.innerHTML = '<strong>Error:</strong> Missing required fields (client_id, client_secret, refresh_token)';
|
|
resultDiv.style.display = 'block';
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const response = await fetch('https://oauth2.googleapis.com/token', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
},
|
|
body: new URLSearchParams({
|
|
client_id: config.client_id,
|
|
client_secret: config.client_secret,
|
|
refresh_token: config.refresh_token,
|
|
grant_type: 'refresh_token',
|
|
}),
|
|
});
|
|
|
|
const data = await response.json();
|
|
const resultText = JSON.stringify(data, null, 2);
|
|
|
|
if (response.ok && data.access_token) {
|
|
resultDiv.className = 'success';
|
|
resultDiv.innerHTML = `
|
|
<h3>✅ Success! Refresh token is valid</h3>
|
|
<p><strong>Access Token:</strong> ${data.access_token.substring(0, 50)}...</p>
|
|
<p><strong>Expires In:</strong> ${data.expires_in} seconds</p>
|
|
<p><strong>Full Response:</strong></p>
|
|
<pre>${resultText}</pre>
|
|
`;
|
|
} else {
|
|
resultDiv.className = 'error';
|
|
resultDiv.innerHTML = `
|
|
<h3>❌ Error</h3>
|
|
<p><strong>Response:</strong></p>
|
|
<pre>${resultText}</pre>
|
|
<p><strong>Possible Issues:</strong></p>
|
|
<ul>
|
|
<li>Refresh token was revoked (check <a href="https://myaccount.google.com/permissions" target="_blank">Google Account permissions</a>)</li>
|
|
<li>OAuth client was deleted from Google Cloud Console</li>
|
|
<li>Client ID or Secret doesn't match</li>
|
|
<li>Refresh token format is incorrect</li>
|
|
</ul>
|
|
`;
|
|
}
|
|
resultDiv.style.display = 'block';
|
|
} catch (error) {
|
|
resultDiv.className = 'error';
|
|
resultDiv.innerHTML = `<strong>Error:</strong> ${error.message}`;
|
|
resultDiv.style.display = 'block';
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|