I am a beginner in angular js and Salesforce.
I am trying to build an application which implements the give link step by step.
Step 1 -> using the below link I got the authentication code
window.location.replace("login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=3MVG9ZL0ppGP5UrCf3JELrQofxaHFFDpsnOhdjkPa8KLI2Z.trnjgMHlJgCQX_FPXdWGzVjLzRzMAZCKxpj4g&redirect_uri=localhost:63342/www/index.html#/&immediate=true");
The redirected url with authentication_code: https://localhost:63342/www/index.html?code=aPrxqJ8A8kLOza9GSNhD7xBRi5wDYopPRYVlQrqIwW.7hGVrixMu3uTfMhnUSHNZzClGdMKahw%3D%3D#/
step 2 -> Next was to get the access token using the above received code
The method is post
url is :login.salesforce.com/services/oauth2/token
And my $http POST method is as follows
$http({
method: 'POST',
url: 'https://login.salesforce.com/services/oauth2/token',
data: {
'grant_type': 'authorization_code',
'code': $scope.code,
'client_id': 'consumer_key',
'client_secret': 'consumer_secret',
'redirect_uri': 'https://localhost:63342/www/index.html#/'
}
}).then(function successCallback(response) {
alert(response.access_token);
}, function errorCallback(response) {
alert(response.error);
});
I tried adding a debugger and got to know that control never goes to success function rather it always goes to error function.
FYI: $scope.code is giving perfectly fine results.
Please see if there is any error I am doing.
Thanks in advance.
EDIT: I am getting an error as
