Maurits van der Schee 5 gadus atpakaļ
vecāks
revīzija
c84456109c
1 mainītis faili ar 33 papildinājumiem un 0 dzēšanām
  1. 33
    0
      examples/clients/auth.php/vanilla.html

+ 33
- 0
examples/clients/auth.php/vanilla.html Parādīt failu

@@ -0,0 +1,33 @@
1
+<html>
2
+<head>
3
+<meta charset="utf-8" /> 
4
+<script>
5
+var authUrl = 'authorize.php'; // hostname ending in '.auth0.com'
6
+var clientId = 'default'; // client id as defined in auth0
7
+var audience = 'api.php'; // api audience as defined in auth0
8
+window.onload = function () {
9
+    var match = RegExp('[#&]access_token=([^&]*)').exec(window.location.hash);
10
+    var accessToken = match && decodeURIComponent(match[1].replace(/\+/g, ' '));
11
+    if (!accessToken) {
12
+        document.location = authUrl+'?audience='+audience+'&response_type=token&client_id='+clientId+'&redirect_uri='+document.location.href;
13
+    } else {
14
+        document.location.hash = '';
15
+        var req = new XMLHttpRequest();
16
+        req.onreadystatechange = function () {
17
+            if (req.readyState==4) {
18
+                console.log(req.responseText);
19
+                document.getElementById('output').innerHTML = JSON.stringify(JSON.parse(req.responseText), undefined, 4);
20
+            }
21
+        }
22
+        url = 'api.php/records/posts?join=categories&join=tags&join=comments&filter=id,eq,1';
23
+        req.open("GET", url, true);
24
+        req.setRequestHeader('X-Authorization', 'Bearer '+accessToken);
25
+        req.send();
26
+    }
27
+};
28
+</script>
29
+</head>
30
+<body>
31
+<pre id="output"></pre>
32
+</body>
33
+</html>

Notiek ielāde…
Atcelt
Saglabāt