I need to get access token and refresh token by exchanging authorization code , i have succeeded in getting authorization code and allow access but not able to get access token and refresh token ,
<html>
<head>
<script>
function auth() {
var config = {
'client_id':'some id',
' access_type':'offline',
'approval_prompt': 'force',
'response_type':'code',
};
gapi.auth.authorize(config, function() {
var code = gapi.auth.getToken().code;
sendRequest(gapi.auth.getToken().code);
console.log (code);
});
}
function sendRequest(code) {
var restRequest = gapi.client.request({
'method':'POST',
'params': {
'code': code,
'client_id': 'some id',
'client_secret':'tsome id',
'grant_type':'authorization_code',
},
'headers': {
'Content-type': 'application/json'
},
});
restRequest.execute(function(jsonResponse, rawResponse) {
rest = jsonResponse;
});
}
</script>
<body>
<button onclick="auth();">Authorize</button>
</body>
</html>
I always get "POST 404 (NOT FOUND)" error.And i am stuck with this from many days.
Any help would be appreciated.
SS237.