Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

105 Zeilen
2.7 KiB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>TOKEN TEST</title>
  5. </head>
  6. <body>
  7. <script>
  8. let args = {
  9. "url": "https://192.168.1.3:10002/realms/API.Server.local/protocol/openid-connect/token",
  10. "options": {
  11. "method": "POST",
  12. "headers": {
  13. "Content-Type": "application/x-www-form-urlencoded"
  14. },
  15. "body": "grant_type=client_credentials&client_id=Fastapi&client_secret=wojuoB7Z5xhlPFrF2lIxJSSdVHCApEgC"
  16. }
  17. };
  18. /*
  19. var url = 'https://192.168.1.3:10002/realms/API.Server.local/protocol/openid-connect/token';
  20. var params = 'grant_type=client_credentials&client_id=Fastapi&client_secret=wojuoB7Z5xhlPFrF2lIxJSSdVHCApEgC';
  21. // METHOD 1 (fetch POST)
  22. let args = {
  23. "url": "https://192.168.1.3:10002/realms/API.Server.local/protocol/openid-connect/token",
  24. "options": {
  25. "method": "POST",
  26. "headers": {
  27. "Content-Type": "application/x-www-form-urlencoded"
  28. },
  29. "body": params
  30. }
  31. };
  32. */
  33. 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);})
  34. // METHOD 2 (XMLHttpRequest POST)
  35. /*
  36. var result;
  37. var http = new XMLHttpRequest();
  38. http.open('POST', url, true);
  39. //Send the proper header information along with the request
  40. http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
  41. http.onreadystatechange = function() {//Call a function when the state changes.
  42. console.log('readystatechange');
  43. if(http.readyState == 4 && http.status == 200) {
  44. console.log(http.responseText);
  45. } else {
  46. }
  47. }
  48. http.send(params);
  49. console.log('result');
  50. console.log(result);
  51. */
  52. // METHOD 3 (XMLHttpRequest GET)
  53. /*
  54. var xmlHttp = new XMLHttpRequest();
  55. xmlHttp.open( "GET", 'https://192.168.1.3:10002/realms/API.Server.local/protocol/openid-connect/token?' + new URLSearchParams({
  56. "grant_type":"client_credentials",
  57. "client_id":"Fastapi",
  58. "client_secret":"wojuoB7Z5xhlPFrF2lIxJSSdVHCApEgC"
  59. }), false ); // false for synchronous request
  60. xmlHttp.send( null );
  61. let result = xmlHttp.responseText;
  62. console.log('result');
  63. console.log(result);
  64. */
  65. /*
  66. // METHOD 4 (fetch GET)
  67. let result = fetch('https://192.168.1.3:10002/realms/API.Server.local/protocol/openid-connect/token?' + new URLSearchParams({
  68. "grant_type":"client_credentials",
  69. "client_id":"Fastapi",
  70. "client_secret":"wojuoB7Z5xhlPFrF2lIxJSSdVHCApEgC"
  71. }).toString())
  72. console.log('result');
  73. console.log(result);
  74. */
  75. </script>
  76. </body>
  77. </html>