easier to test client forcing HTTPS
This commit is contained in:
parent
be139403bb
commit
afe1371fb1
7 changed files with 488 additions and 0 deletions
204
callback
Normal file
204
callback
Normal file
|
@ -0,0 +1,204 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>OAuth2 Demo Login</title>
|
||||||
|
<link rel="stylesheet" href="brutalist.css" />
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||||
|
<script src="./infos.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
</script>
|
||||||
|
<h1>Yolo App login page</h1>
|
||||||
|
<p>Authorization process done!</p>
|
||||||
|
<a href="/index.html">← go back to main page</a>
|
||||||
|
<h2>Authorization Status</h2>
|
||||||
|
<pre class="code" id="authorization_status"></pre>
|
||||||
|
<div id="error-info"></div>
|
||||||
|
<h3>State</h3>
|
||||||
|
The process should also return the state provided.
|
||||||
|
<pre class="code" id="state-param"></pre>
|
||||||
|
<div id="oncode">
|
||||||
|
<h2>Code</h2>
|
||||||
|
<p>The code is generated by the Authentication server and send back
|
||||||
|
to the client via the resource's owner user-agent</p>
|
||||||
|
<p>For us, it is a JWT:</p>
|
||||||
|
<pre class="code" id="code-param"></pre>
|
||||||
|
<p>Which once decoded is:</p>
|
||||||
|
<pre class="code" id="code-token"></pre>
|
||||||
|
<h2>Tokens</h2>
|
||||||
|
<p> Now the client server need to retrieve an <em>Access Token</em>
|
||||||
|
and a <em>Refresh Token</em> by using that code.</p>
|
||||||
|
<p>To achieve that the client will make a call to <code>/token</code>
|
||||||
|
using a basic auth creds</p>
|
||||||
|
<p>You have about 10 mins to retrieve them.
|
||||||
|
Unlike in this demo, that <strong>MUST</strong> be done server side.</p>
|
||||||
|
<div class="button"
|
||||||
|
onclick="getTokensFromCode();">
|
||||||
|
Get Access & Refresh Tokens from Code
|
||||||
|
</div>
|
||||||
|
<h3>Response from <code>/token</code></h3>
|
||||||
|
<p>token endpoint URL: <code id="urltoken" class="code">Nothing yet.</code></p>
|
||||||
|
<pre id="token" class="code">Nothing yet.</pre>
|
||||||
|
<h3>decoded access-token</h3>
|
||||||
|
<pre id="access-token" class="code">Nothing yet.</pre>
|
||||||
|
<h3>decoded refresh-token</h3>
|
||||||
|
<pre id="refresh-token" class="code">Nothing yet.</pre>
|
||||||
|
<h2>Using the API</h2>
|
||||||
|
<div class="button"
|
||||||
|
onclick="makeApiCall();">
|
||||||
|
Make an API call with the access token
|
||||||
|
</div>
|
||||||
|
<p>API URL: <code id="apiurl" class="code">Nothing yet.</code></p>
|
||||||
|
<pre id="apiresponse" class="code">Nothing yet.</pre>
|
||||||
|
<h2>Getting new access token without user interaction</h2>
|
||||||
|
<p> The access tokens are the only tokens which are able to talk to the
|
||||||
|
Visibility API.</p>
|
||||||
|
<p>Access tokens live a short time (about 10 min to 1 hour)</p>
|
||||||
|
<p>This is why the client must require a new access token using its
|
||||||
|
<em>refresh token</em>.
|
||||||
|
That is just making another call to <code>/token</code>
|
||||||
|
But with different parameters. </p>
|
||||||
|
<div class="button"
|
||||||
|
onclick="getAccessToken();">
|
||||||
|
Get Access Tokens from Refresh Token
|
||||||
|
</div>
|
||||||
|
<pre id="refreshed" class="code">Nothing yet.</pre>
|
||||||
|
<pre id="refreshed-access-token" class="code">Nothing yet.</pre>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
/* ----- */
|
||||||
|
function getJsonFromUrl() {
|
||||||
|
var query = location.search.substr(1);
|
||||||
|
var result = {};
|
||||||
|
query.split("&").forEach(function(part) {
|
||||||
|
var item = part.split("=");
|
||||||
|
result[item[0]] = decodeURIComponent(item[1]);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
var params=getJsonFromUrl();
|
||||||
|
var authstatus="";
|
||||||
|
if (params.error) {
|
||||||
|
authstatus = "REFUSED: " + params.error;
|
||||||
|
if (params.error_description) {
|
||||||
|
authstatus += "\n\n" + params.error_description;
|
||||||
|
}
|
||||||
|
if (params.error_uri) {
|
||||||
|
authstatus += "<a href='" + params.error_uri + "'>" + params.error_uri + "</a>";
|
||||||
|
}
|
||||||
|
$('#authorization_status').addClass('refused');
|
||||||
|
$('#oncode').hide();
|
||||||
|
} else {
|
||||||
|
if (params.code) {
|
||||||
|
authstatus = "AUTHORIZED" ;
|
||||||
|
$('#authorization_status').addClass('authorized');
|
||||||
|
} else {
|
||||||
|
authstatus = "UNKNOWN" ;
|
||||||
|
$('#oncode').hide();
|
||||||
|
$('#state-param').html("No state");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$('#urltoken').html( oauthServerTokenUrl );
|
||||||
|
$('#apiurl').html( resourceProviderTestEndpoint );
|
||||||
|
$('#authorization_status').html( authstatus );
|
||||||
|
$('#state-param').html(params.state);
|
||||||
|
if (params.error_uri) {
|
||||||
|
var erroruri=decodeURIComponent(params.error_uri);
|
||||||
|
$('#error-info').html("<p>You can have more informations here:</p><a href=\"" + erroruri + "\" target=\"_blank\">" + erroruri + "</a>");
|
||||||
|
}
|
||||||
|
|
||||||
|
function jwtDecode(t) {
|
||||||
|
let token = {};
|
||||||
|
token.raw = t;
|
||||||
|
token.header = JSON.parse(window.atob(t.split('.')[0]));
|
||||||
|
token.payload = JSON.parse(window.atob(t.split('.')[1]));
|
||||||
|
return (token)
|
||||||
|
}
|
||||||
|
var jwt=jwtDecode(params.code).payload;
|
||||||
|
$('#code-param').html(params.code);
|
||||||
|
$('#code-token').html(JSON.stringify(jwt,null,2));
|
||||||
|
var refreshToken="";
|
||||||
|
var accessToken="";
|
||||||
|
var getTokensFromCode = function() {
|
||||||
|
var tokparams={
|
||||||
|
"code":params.code
|
||||||
|
, "redirect_uri":redirect_uri
|
||||||
|
, "scope":scope
|
||||||
|
, "client_id":client_id
|
||||||
|
, "grant_type":"authorization_code"
|
||||||
|
};
|
||||||
|
var onError = function(jqXHR,textStatus,errorThrown){
|
||||||
|
$('#token').html(errorThrown + " status: " + jqXHR.status
|
||||||
|
+ "\n---\n"
|
||||||
|
+ JSON.stringify(jqXHR.responseJSON,null,2));}
|
||||||
|
var onSuccess = function(data,textStatus,jqXHR) {
|
||||||
|
$("#token").html(data
|
||||||
|
+ "\n---\n"
|
||||||
|
+ JSON.stringify(jqXHR.responseJSON,null,2));
|
||||||
|
$("#access-token").html( JSON.stringify(jwtDecode(jqXHR.responseJSON.access_token).payload,null,2) );
|
||||||
|
$("#refresh-token").html( JSON.stringify(jwtDecode(jqXHR.responseJSON.refresh_token).payload,null,2) );
|
||||||
|
accessToken=jqXHR.responseJSON.access_token;
|
||||||
|
refreshToken=jqXHR.responseJSON.refresh_token;
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
type: "POST"
|
||||||
|
, beforeSend: function(request) {request.setRequestHeader("Authorization","Basic " + btoa(client_id + ":" + client_password))}
|
||||||
|
, success: onSuccess
|
||||||
|
, error: onError
|
||||||
|
, url: oauthServerTokenUrl
|
||||||
|
, data: tokparams
|
||||||
|
, contentType: 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||||
|
, crossDomain: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
var getAccessToken = function() {
|
||||||
|
var tokparams={
|
||||||
|
"refresh_token":refreshToken
|
||||||
|
, "scope":scope
|
||||||
|
, "client_id":client_id
|
||||||
|
, "grant_type":"refresh_token"
|
||||||
|
};
|
||||||
|
var onError = function(jqXHR,textStatus,errorThrown){
|
||||||
|
$('#refreshed').html(errorThrown + " status: " + jqXHR.status
|
||||||
|
+ "\n---\n"
|
||||||
|
+ JSON.stringify(jqXHR.responseJSON,null,2))}
|
||||||
|
var onSuccess = function(data,textStatus,jqXHR) {
|
||||||
|
$("#refreshed").html(data
|
||||||
|
+ "\n---\n"
|
||||||
|
+ JSON.stringify(jqXHR.responseJSON,null,2));
|
||||||
|
$("#refreshed-access-token").html( JSON.stringify(jwtDecode(jqXHR.responseJSON.access_token).payload,null,2) );
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
type: "POST"
|
||||||
|
, beforeSend: function(request) {request.setRequestHeader("Authorization","Basic " + btoa(client_id + ":" + client_password))}
|
||||||
|
, success: onSuccess
|
||||||
|
, error: onError
|
||||||
|
, url: oauthServerTokenUrl
|
||||||
|
, data: tokparams
|
||||||
|
, contentType: 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||||
|
, crossDomain: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
var makeApiCall = function() {
|
||||||
|
var onError = function(jqXHR,textStatus,errorThrown){
|
||||||
|
$('#apiresponse').html(errorThrown + " status: " + jqXHR.status
|
||||||
|
+ "\n---\n"
|
||||||
|
+ JSON.stringify(jqXHR.responseJSON,null,2))}
|
||||||
|
var onSuccess = function(data,textStatus,jqXHR) {
|
||||||
|
$("#apiresponse").html(data
|
||||||
|
+ "\n---\n"
|
||||||
|
+ JSON.stringify(jqXHR.responseJSON,null,2));}
|
||||||
|
$.ajax({
|
||||||
|
type: "GET"
|
||||||
|
, beforeSend: function(request) {request.setRequestHeader("Authorization","Bearer " + accessToken)}
|
||||||
|
, success: onSuccess
|
||||||
|
, error: onError
|
||||||
|
, url: resourceProviderTestEndpoint
|
||||||
|
, contentType: 'application/json'
|
||||||
|
, crossDomain: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
21
cert.pem
Normal file
21
cert.pem
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDfjCCAmYCCQCkePR4pS0CNjANBgkqhkiG9w0BAQsFADCBgDELMAkGA1UEBhMC
|
||||||
|
RlIxDzANBgNVBAgMBkZyYW5jZTEQMA4GA1UEBwwHTW91Z2luczEOMAwGA1UECgwF
|
||||||
|
Q2lzY28xDTALBgNVBAsMBElST0gxDDAKBgNVBAMMA0NUUjEhMB8GCSqGSIb3DQEJ
|
||||||
|
ARYSeWFlc3Bvc2lAY2lzY28uY29tMB4XDTE4MTAxMTA4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6LgmRxgnb2mPr2LBf5NqliqdILg==
|
||||||
|
-----END CERTIFICATE-----
|
BIN
infos.js.gpg
Normal file
BIN
infos.js.gpg
Normal file
Binary file not shown.
30
key.pem
Normal file
30
key.pem
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||||
|
MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIqIPBaCV4dboCAggA
|
||||||
|
MB0GCWCGSAFlAwQBKgQQ40H1LVEAqcn6NxyeVmGMGgSCBNBwlIRFA/GH3vCTdx1p
|
||||||
|
shrFQZbLpLdvK7HVk5mo8Mhdvj3xPqAhBMTdrSDKPJe+YfOoZVplhvttMB2WxIlj
|
||||||
|
ubXf+Xr+8RdmygpfvxuGaVlfHH07IfOuqIrV/W0r9FocrCKUjRBUXnhx1L9CA4pB
|
||||||
|
LrW4xtXgmqh+gzWv8pWfUB6wTJnsCrWvC/FJeWGW6CwejuGcGTekWreqnZzmB575
|
||||||
|
CoiOVG76dYG2gAgDX/Y7ucyUGS9QfNuDxElCwu65M+7nicAPKunYkN3Dn2PG6GeD
|
||||||
|
3ama/Iuf8/3J6UWcYGXiY+WIm/js71ZCHHvK31IsuNRWDkphr5oGRydC5P2CEgSB
|
||||||
|
xb0c0RA8TJbgH/IIeF8rV0h+OvNIToXI8gNLasW5lFjx5MnM0tvkmokcyXX2NpOI
|
||||||
|
QA6qhxQLfKRLPTuV1JKg46udcOohW0qLv8sz9FX3eK9gF195u6o/Qk75r7oQlppd
|
||||||
|
o3HGcxNNxBwHYB1YqixVLUP6aPTkccbodHz5Bu4AAzgS4xHYaVE+RgVgGLiTK9WF
|
||||||
|
eWWnXt0HcixPLUZtifCdZx/J4Or51VqJGGOf2RHZa1GV3TzWG+0DdF8VaY9D/4n5
|
||||||
|
LBx+2CBZM3vQwXEZhm3kOAA0889eTJ7wq6Va5CAPp+02saV4HRK1ae7gGU+SuX4X
|
||||||
|
rG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r6XP6bSpTjjvCPRm0DwPnw8C4I
|
||||||
|
Gi5TUJGHzcQrVY6FEQHS1pIL+A==
|
||||||
|
-----END ENCRYPTED PRIVATE KEY-----
|
204
login.html
Normal file
204
login.html
Normal file
|
@ -0,0 +1,204 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>OAuth2 Demo Login</title>
|
||||||
|
<link rel="stylesheet" href="brutalist.css" />
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||||
|
<script src="./infos.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
</script>
|
||||||
|
<h1>Yolo App login page</h1>
|
||||||
|
<p>Authorization process done!</p>
|
||||||
|
<a href="/index.html">← go back to main page</a>
|
||||||
|
<h2>Authorization Status</h2>
|
||||||
|
<pre class="code" id="authorization_status"></pre>
|
||||||
|
<div id="error-info"></div>
|
||||||
|
<h3>State</h3>
|
||||||
|
The process should also return the state provided.
|
||||||
|
<pre class="code" id="state-param"></pre>
|
||||||
|
<div id="oncode">
|
||||||
|
<h2>Code</h2>
|
||||||
|
<p>The code is generated by the Authentication server and send back
|
||||||
|
to the client via the resource's owner user-agent</p>
|
||||||
|
<p>For us, it is a JWT:</p>
|
||||||
|
<pre class="code" id="code-param"></pre>
|
||||||
|
<p>Which once decoded is:</p>
|
||||||
|
<pre class="code" id="code-token"></pre>
|
||||||
|
<h2>Tokens</h2>
|
||||||
|
<p> Now the client server need to retrieve an <em>Access Token</em>
|
||||||
|
and a <em>Refresh Token</em> by using that code.</p>
|
||||||
|
<p>To achieve that the client will make a call to <code>/token</code>
|
||||||
|
using a basic auth creds</p>
|
||||||
|
<p>You have about 10 mins to retrieve them.
|
||||||
|
Unlike in this demo, that <strong>MUST</strong> be done server side.</p>
|
||||||
|
<div class="button"
|
||||||
|
onclick="getTokensFromCode();">
|
||||||
|
Get Access & Refresh Tokens from Code
|
||||||
|
</div>
|
||||||
|
<h3>Response from <code>/token</code></h3>
|
||||||
|
<p>token endpoint URL: <code id="urltoken" class="code">Nothing yet.</code></p>
|
||||||
|
<pre id="token" class="code">Nothing yet.</pre>
|
||||||
|
<h3>decoded access-token</h3>
|
||||||
|
<pre id="access-token" class="code">Nothing yet.</pre>
|
||||||
|
<h3>decoded refresh-token</h3>
|
||||||
|
<pre id="refresh-token" class="code">Nothing yet.</pre>
|
||||||
|
<h2>Using the API</h2>
|
||||||
|
<div class="button"
|
||||||
|
onclick="makeApiCall();">
|
||||||
|
Make an API call with the access token
|
||||||
|
</div>
|
||||||
|
<p>API URL: <code id="apiurl" class="code">Nothing yet.</code></p>
|
||||||
|
<pre id="apiresponse" class="code">Nothing yet.</pre>
|
||||||
|
<h2>Getting new access token without user interaction</h2>
|
||||||
|
<p> The access tokens are the only tokens which are able to talk to the
|
||||||
|
Visibility API.</p>
|
||||||
|
<p>Access tokens live a short time (about 10 min to 1 hour)</p>
|
||||||
|
<p>This is why the client must require a new access token using its
|
||||||
|
<em>refresh token</em>.
|
||||||
|
That is just making another call to <code>/token</code>
|
||||||
|
But with different parameters. </p>
|
||||||
|
<div class="button"
|
||||||
|
onclick="getAccessToken();">
|
||||||
|
Get Access Tokens from Refresh Token
|
||||||
|
</div>
|
||||||
|
<pre id="refreshed" class="code">Nothing yet.</pre>
|
||||||
|
<pre id="refreshed-access-token" class="code">Nothing yet.</pre>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
/* ----- */
|
||||||
|
function getJsonFromUrl() {
|
||||||
|
var query = location.search.substr(1);
|
||||||
|
var result = {};
|
||||||
|
query.split("&").forEach(function(part) {
|
||||||
|
var item = part.split("=");
|
||||||
|
result[item[0]] = decodeURIComponent(item[1]);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
var params=getJsonFromUrl();
|
||||||
|
var authstatus="";
|
||||||
|
if (params.error) {
|
||||||
|
authstatus = "REFUSED: " + params.error;
|
||||||
|
if (params.error_description) {
|
||||||
|
authstatus += "\n\n" + params.error_description;
|
||||||
|
}
|
||||||
|
if (params.error_uri) {
|
||||||
|
authstatus += "<a href='" + params.error_uri + "'>" + params.error_uri + "</a>";
|
||||||
|
}
|
||||||
|
$('#authorization_status').addClass('refused');
|
||||||
|
$('#oncode').hide();
|
||||||
|
} else {
|
||||||
|
if (params.code) {
|
||||||
|
authstatus = "AUTHORIZED" ;
|
||||||
|
$('#authorization_status').addClass('authorized');
|
||||||
|
} else {
|
||||||
|
authstatus = "UNKNOWN" ;
|
||||||
|
$('#oncode').hide();
|
||||||
|
$('#state-param').html("No state");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$('#urltoken').html( oauthServerTokenUrl );
|
||||||
|
$('#apiurl').html( resourceProviderTestEndpoint );
|
||||||
|
$('#authorization_status').html( authstatus );
|
||||||
|
$('#state-param').html(params.state);
|
||||||
|
if (params.error_uri) {
|
||||||
|
var erroruri=decodeURIComponent(params.error_uri);
|
||||||
|
$('#error-info').html("<p>You can have more informations here:</p><a href=\"" + erroruri + "\" target=\"_blank\">" + erroruri + "</a>");
|
||||||
|
}
|
||||||
|
|
||||||
|
function jwtDecode(t) {
|
||||||
|
let token = {};
|
||||||
|
token.raw = t;
|
||||||
|
token.header = JSON.parse(window.atob(t.split('.')[0]));
|
||||||
|
token.payload = JSON.parse(window.atob(t.split('.')[1]));
|
||||||
|
return (token)
|
||||||
|
}
|
||||||
|
var jwt=jwtDecode(params.code).payload;
|
||||||
|
$('#code-param').html(params.code);
|
||||||
|
$('#code-token').html(JSON.stringify(jwt,null,2));
|
||||||
|
var refreshToken="";
|
||||||
|
var accessToken="";
|
||||||
|
var getTokensFromCode = function() {
|
||||||
|
var tokparams={
|
||||||
|
"code":params.code
|
||||||
|
, "redirect_uri":redirect_uri
|
||||||
|
, "scope":scope
|
||||||
|
, "client_id":client_id
|
||||||
|
, "grant_type":"authorization_code"
|
||||||
|
};
|
||||||
|
var onError = function(jqXHR,textStatus,errorThrown){
|
||||||
|
$('#token').html(errorThrown + " status: " + jqXHR.status
|
||||||
|
+ "\n---\n"
|
||||||
|
+ JSON.stringify(jqXHR.responseJSON,null,2));}
|
||||||
|
var onSuccess = function(data,textStatus,jqXHR) {
|
||||||
|
$("#token").html(data
|
||||||
|
+ "\n---\n"
|
||||||
|
+ JSON.stringify(jqXHR.responseJSON,null,2));
|
||||||
|
$("#access-token").html( JSON.stringify(jwtDecode(jqXHR.responseJSON.access_token).payload,null,2) );
|
||||||
|
$("#refresh-token").html( JSON.stringify(jwtDecode(jqXHR.responseJSON.refresh_token).payload,null,2) );
|
||||||
|
accessToken=jqXHR.responseJSON.access_token;
|
||||||
|
refreshToken=jqXHR.responseJSON.refresh_token;
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
type: "POST"
|
||||||
|
, beforeSend: function(request) {request.setRequestHeader("Authorization","Basic " + btoa(client_id + ":" + client_password))}
|
||||||
|
, success: onSuccess
|
||||||
|
, error: onError
|
||||||
|
, url: oauthServerTokenUrl
|
||||||
|
, data: tokparams
|
||||||
|
, contentType: 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||||
|
, crossDomain: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
var getAccessToken = function() {
|
||||||
|
var tokparams={
|
||||||
|
"refresh_token":refreshToken
|
||||||
|
, "scope":scope
|
||||||
|
, "client_id":client_id
|
||||||
|
, "grant_type":"refresh_token"
|
||||||
|
};
|
||||||
|
var onError = function(jqXHR,textStatus,errorThrown){
|
||||||
|
$('#refreshed').html(errorThrown + " status: " + jqXHR.status
|
||||||
|
+ "\n---\n"
|
||||||
|
+ JSON.stringify(jqXHR.responseJSON,null,2))}
|
||||||
|
var onSuccess = function(data,textStatus,jqXHR) {
|
||||||
|
$("#refreshed").html(data
|
||||||
|
+ "\n---\n"
|
||||||
|
+ JSON.stringify(jqXHR.responseJSON,null,2));
|
||||||
|
$("#refreshed-access-token").html( JSON.stringify(jwtDecode(jqXHR.responseJSON.access_token).payload,null,2) );
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
type: "POST"
|
||||||
|
, beforeSend: function(request) {request.setRequestHeader("Authorization","Basic " + btoa(client_id + ":" + client_password))}
|
||||||
|
, success: onSuccess
|
||||||
|
, error: onError
|
||||||
|
, url: oauthServerTokenUrl
|
||||||
|
, data: tokparams
|
||||||
|
, contentType: 'application/x-www-form-urlencoded; charset=UTF-8'
|
||||||
|
, crossDomain: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
var makeApiCall = function() {
|
||||||
|
var onError = function(jqXHR,textStatus,errorThrown){
|
||||||
|
$('#apiresponse').html(errorThrown + " status: " + jqXHR.status
|
||||||
|
+ "\n---\n"
|
||||||
|
+ JSON.stringify(jqXHR.responseJSON,null,2))}
|
||||||
|
var onSuccess = function(data,textStatus,jqXHR) {
|
||||||
|
$("#apiresponse").html(data
|
||||||
|
+ "\n---\n"
|
||||||
|
+ JSON.stringify(jqXHR.responseJSON,null,2));}
|
||||||
|
$.ajax({
|
||||||
|
type: "GET"
|
||||||
|
, beforeSend: function(request) {request.setRequestHeader("Authorization","Bearer " + accessToken)}
|
||||||
|
, success: onSuccess
|
||||||
|
, error: onError
|
||||||
|
, url: resourceProviderTestEndpoint
|
||||||
|
, contentType: 'application/json'
|
||||||
|
, crossDomain: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
27
nopasskey.pem
Normal file
27
nopasskey.pem
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIIEpAIBAAKCAQEAxxJxLRgMKMl1MxsYVgIubqLFw21kkCmoEzeEHk65I5jTk9d+
|
||||||
|
i95++M9AuDDUESggPLPDL/lkxaDGwWyqoxosIBZyO46+ZGzX9ErOeOSI8a+JnQIr
|
||||||
|
N55D4tj1J2xG3A0zRpsHg53bQSOQxG7syTVybnMb/zL442dPxkKEMVPfA9aYpt+0
|
||||||
|
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b04+3mvpyebmpb4XbESNfN
|
||||||
|
wbNuD79zds2mFvAmSLTdDb/kSHt4ZYQpWKIgFJu7RT5ScqViB+xb83PAPVRJhFj9
|
||||||
|
GW0hvv6tgxXdiDSJb6ZxOnUCgYB3DzYHeId0Pv3+sMM+WLLZtI3oUmQURVIykP4r
|
||||||
|
bGVCbVoQ+5fcEs0x3ARQGhkKYsvOiFAKk14KMeqNEJKf4W0mwYhwjJxVBnieoh1Z
|
||||||
|
FE+z6NQullDnpBRw+/PTPPA35c/+6gWa9LXwpZ9B7a/036q08zUMTz6z+GryZe2q
|
||||||
|
W78iRQKBgQDC3sajFjIxLs5uXKMVIWhj8JXaDh35EhknTxOPIoXjoNUOn4YeALYs
|
||||||
|
tVm7rGmaLlG+R78mqWEPmWBNOG9PUCfyfaRWYrxHu0ZGirwK7g9sWaawpW5sfN0v
|
||||||
|
NztJc4vx/YlAS9SJvbW+uoPTgos4qvJj2Y03kgJ3oV793w+5FQMlqA==
|
||||||
|
-----END RSA PRIVATE KEY-----
|
2
start-server.sh
Normal file
2
start-server.sh
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
sws --local --no-auth . --port 5443 --certificate=cert.pem --key-file=nopasskey.pem -X 'Content-Type: text/html; charset=utf-8'
|
Loading…
Reference in a new issue