|
- <!DOCTYPE html>
- <html>
-
- <head>
-
- <title>TOKEN TEST</title>
-
-
- </head>
-
- <body>
-
- <script>
-
- let args = {
- "url": "https://192.168.1.3:10002/realms/API.Server.local/protocol/openid-connect/token",
- "options": {
- "method": "POST",
- "headers": {
- "Content-Type": "application/x-www-form-urlencoded"
- },
- "body": "grant_type=client_credentials&client_id=Fastapi&client_secret=wojuoB7Z5xhlPFrF2lIxJSSdVHCApEgC"
- }
- };
-
- /*
- var url = 'https://192.168.1.3:10002/realms/API.Server.local/protocol/openid-connect/token';
- var params = 'grant_type=client_credentials&client_id=Fastapi&client_secret=wojuoB7Z5xhlPFrF2lIxJSSdVHCApEgC';
-
-
- // METHOD 1 (fetch POST)
-
- let args = {
- "url": "https://192.168.1.3:10002/realms/API.Server.local/protocol/openid-connect/token",
- "options": {
- "method": "POST",
- "headers": {
- "Content-Type": "application/x-www-form-urlencoded"
- },
- "body": params
- }
- };
- */
-
- if (args.options.body && typeof args.options.body !== 'string') args.options.body = JSON.stringify(args.options.body); fetch(args.url, args.options).then(response => response.json()).then(data => {console.log('fetchJson success'); console.log(data);}).catch((err) => {console.log('fetchJson error');console.log(err);})
-
-
-
- // METHOD 2 (XMLHttpRequest POST)
- /*
- var result;
- var http = new XMLHttpRequest();
- http.open('POST', url, true);
- //Send the proper header information along with the request
- http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
-
- http.onreadystatechange = function() {//Call a function when the state changes.
- console.log('readystatechange');
- if(http.readyState == 4 && http.status == 200) {
- console.log(http.responseText);
- } else {
- }
- }
- http.send(params);
- console.log('result');
- console.log(result);
- */
-
- // METHOD 3 (XMLHttpRequest GET)
-
- /*
- var xmlHttp = new XMLHttpRequest();
- xmlHttp.open( "GET", 'https://192.168.1.3:10002/realms/API.Server.local/protocol/openid-connect/token?' + new URLSearchParams({
-
- "grant_type":"client_credentials",
- "client_id":"Fastapi",
- "client_secret":"wojuoB7Z5xhlPFrF2lIxJSSdVHCApEgC"
-
- }), false ); // false for synchronous request
- xmlHttp.send( null );
- let result = xmlHttp.responseText;
- console.log('result');
- console.log(result);
- */
-
- /*
- // METHOD 4 (fetch GET)
- let result = fetch('https://192.168.1.3:10002/realms/API.Server.local/protocol/openid-connect/token?' + new URLSearchParams({
-
- "grant_type":"client_credentials",
- "client_id":"Fastapi",
- "client_secret":"wojuoB7Z5xhlPFrF2lIxJSSdVHCApEgC"
-
- }).toString())
- console.log('result');
- console.log(result);
- */
-
-
-
- </script>
-
- </body>
-
- </html>
|