Question

i am tyring to get google api token by sendding auth code to google following this guide.

this is my code:

        $http({
            method: 'POST',
            url: 'https://accounts.google.com/o/oauth2/token',
            headers: {'Content-Type': 'application/x-www-form-urlencoded'},
            params : {
                code           : '4/heMv6ozWwCxS5RyTzCgThAgxvRyk.oske-bNEGOUTOl05ti8ZT3YnwwH8iQI',
                client_id      : GoogleAppInfo.clientId,
                 redirect_uri  : GoogleAppInfo.redirect_uri,
                client_secret  : GoogleAppInfo.client_secret,
                grant_type     : 'authorization_code'
            }

        }).
        success(function(data, status, headers, config) {
            alert('secsses');
        }).
        error(function(data, status, headers, config) {
            alert('error');

        });

the reuqest sended but the header is not set! enter image description here

has anyone know what is the problem?

Was it helpful?

Solution

From: Angular, content type is not being sent with $http

"You need to include a body with the request. Angular removes the content-type header otherwise.

Add data: '' to the argument to $http."

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top