Skip to content
This repository was archived by the owner on Apr 14, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions oauth-auth-code/nodejs/my_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,26 @@
<head>
<title>NodeJS Authorization Code</title>

<script src='//code.jquery.com/jquery-1.11.2.min.js'></script>
<script src="//cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<script src='http://code.jquery.com/jquery-1.11.2.min.js'></script>
<script src="http://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>

<script>
$.ajax({
url: "/me",
type: "GET",

success: function(data) {
$('#data').text(JSON.stringify(data));
$.ajax({
url: "/me",
type: "GET",

success: function(data) {
console.log('2nd call succeeded')

}});
}});

</script>
</head>
<body>
Expand Down
5 changes: 4 additions & 1 deletion oauth-auth-code/nodejs/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var authvalidation = function(req, res, next) {
//if we don't have a session then redirect them to the login page
if((req.cookies && !(req.cookies.session && sessionMap[req.cookies.session])) &&
req.url.indexOf("oauth") == -1){
console.log('req', req)
//redirect the user to authorize with purecloud
var redirectUri = "https://login.mypurecloud.com/oauth/authorize?" +
"response_type=code" +
Expand Down Expand Up @@ -101,7 +102,9 @@ app.get("/me", function(req, res){
console.log("Got response for /users/me");
console.log(user);
console.log(e);
res.send(user);
res.send(user);
// clear cache for forcing the 2nd ajax to call;
sessionMap = {};
Copy link
Author

@shanshanzhu shanshanzhu Jul 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this to clear cache so that 2nd ajax is also forcing a redirect call to purecloud

})
});

Expand Down
Loading