0

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?

2
  • did you really send it? It looks like you're sending a cross-domain request. Commented Mar 26, 2014 at 12:08
  • yes. i sent the request, this is from firefox console after i got the bad response. Commented Mar 26, 2014 at 12:13

1 Answer 1

1

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."

Sign up to request clarification or add additional context in comments.

3 Comments

thanks! that worked. the header was added. but it didnt solve the problem. google server still retirives bad request eror.
I suggest adding another question perhaps with different tags now that the problem has shifted to communicating with the google server. I do not have experience with that, sorry.
well i have dont that. thanks for the help. my other question is stackoverflow.com/questions/22661673/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.