$
.
ajax
({
url
:
SERVER_URL
+
"/oauth/token"
,
method
:
"POST"
,
data
:
{
grant_type
:
"refresh_token"
,
client_id
:
CLIENT_ID
,
client_secret
:
CLIENT_SECRET
,
refresh_token
:
refreshToken
},
timeout
:
8000
,
dataType
:
"json"
,
cache
:
false
,
beforeSend
:
function
(xhr)
{
//Nothing yet
},
error
:
function
(data,
textStatus)
{
if
(textStatus
===
"timeout"
||
textStatus
===
"error"
)
{
console
.
log
(
"checkRefreshToken - Ajax - Error"
);
returnToLoginOnError
();
}
},
statusCode
:
{
//If status is 200
200
:
function
(response)
{
checkAuthorizationAndRole
(
response
.
access_token
,
response
.
refresh_token
);
},
401
:
function
(response)
{
//Unauthenticated
returnToLoginOnError
();
console
.
log
(
"checkRefreshToken - 401 - Unauthenticated"
);
},
404
:
function
(response)
{
//Bad Url
console
.
log
(
response
.
message
);
notificationSendingReport
.
close
();
notificationError404
.
open
();
},
500
:
function
(response)
{
//ERROR
console
.
log
(
response
.
message
);
notificationSendingReport
.
close
();
notificationError500
.
open
();
},
503
:
function
(response)
{
//ERROR
console
.
log
(
response
.
message
);
notificationSendingReport
.
close
();
notificationError500
.
open
();
}
}
});
}