-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-oauth.php
More file actions
123 lines (114 loc) · 5.89 KB
/
debug-oauth.php
File metadata and controls
123 lines (114 loc) · 5.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
require_once 'config.php';
// Página de debug para verificar configurações OAuth
?>
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Debug OAuth - SUPACO</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-dark text-white">
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card bg-dark border-secondary">
<div class="card-header">
<h3 class="mb-0">🔧 Debug OAuth Configuration</h3>
</div>
<div class="card-body">
<h5>📋 Configurações Atuais</h5>
<table class="table table-dark table-striped">
<tbody>
<tr>
<td><strong>Ambiente:</strong></td>
<td><?php echo $isLocalhost ? 'Local' : 'Produção'; ?></td>
</tr>
<tr>
<td><strong>SUAP URL:</strong></td>
<td><?php echo SUAP_URL; ?></td>
</tr>
<tr>
<td><strong>Client ID:</strong></td>
<td><?php echo SUAP_CLIENT_ID; ?></td>
</tr>
<tr>
<td><strong>Redirect URI:</strong></td>
<td><code><?php echo REDIRECT_URI; ?></code></td>
</tr>
<tr>
<td><strong>SERVER_NAME:</strong></td>
<td><?php echo $_SERVER['SERVER_NAME']; ?></td>
</tr>
<tr>
<td><strong>HTTP_HOST:</strong></td>
<td><?php echo $_SERVER['HTTP_HOST']; ?></td>
</tr>
<tr>
<td><strong>HTTPS:</strong></td>
<td><?php echo isset($_SERVER['HTTPS']) ? 'Sim' : 'Não'; ?></td>
</tr>
</tbody>
</table>
<h5>🔗 URL de Autorização</h5>
<div class="alert alert-info">
<strong>URL completa:</strong><br>
<code><?php
$auth_url = SUAP_URL . "/o/authorize/?" . http_build_query([
'response_type' => 'code',
'client_id' => SUAP_CLIENT_ID,
'redirect_uri' => REDIRECT_URI
]);
echo $auth_url;
?></code>
</div>
<h5>🧪 Testes</h5>
<div class="d-grid gap-2">
<a href="<?php echo $auth_url; ?>" class="btn btn-primary" target="_blank">
🚀 Testar Autorização
</a>
<a href="callback.php" class="btn btn-secondary">
📞 Testar Callback (sem código)
</a>
<button class="btn btn-warning" onclick="copyToClipboard('<?php echo REDIRECT_URI; ?>')">
📋 Copiar Redirect URI
</button>
</div>
<h5 class="mt-4">📝 Logs do Servidor</h5>
<div class="alert alert-warning">
<small>
Verifique os logs do servidor para mais detalhes:<br>
<code>C:\wamp64\logs\php_error.log</code>
</small>
</div>
<h5>🔍 Possíveis Problemas</h5>
<ul class="list-unstyled">
<li>❌ <strong>Redirect URI não registrado:</strong> Verifique no painel OAuth do SUAP</li>
<li>❌ <strong>Protocolo incorreto:</strong> Deve ser HTTPS em produção</li>
<li>❌ <strong>Domínio incorreto:</strong> Verifique se o domínio está correto</li>
<li>❌ <strong>Caminho incorreto:</strong> Deve ser exatamente <code>/callback.php</code></li>
<li>❌ <strong>Client ID incorreto:</strong> Verifique se está usando o ID correto</li>
</ul>
<div class="alert alert-danger">
<strong>⚠️ Importante:</strong><br>
O redirect URI deve estar <strong>exatamente</strong> como registrado no SUAP.<br>
Qualquer diferença (protocolo, domínio, caminho, barra final) causará erro.
</div>
</div>
</div>
</div>
</div>
</div>
<script>
function copyToClipboard(text) {
navigator.clipboard.writeText(text).then(function() {
alert('Redirect URI copiado para a área de transferência!');
}, function(err) {
console.error('Erro ao copiar: ', err);
});
}
</script>
</body>
</html>