Hello,

I am trying to request an access token from the AdWords API using a Google 
Script.  Here is my current code:

function requestAccessToken(){
  var url = "https://accounts.google.com/o/oauth2/token";
  var options = {
    headers:{
     ContentType:'application/x-www-form-urlencoded'
    },
    grant_type:encodeURIComponent('authorization_code'),
    
code:encodeURIComponent('4/Pi3-JwaCbQI_GLJCrNUYmwZKcanO.UqVdYBt8IgkcshQV0ieZDArqIHDljAI'),
    client_secret:encodeURIComponent('*****'),
    redirect_uri:encodeURIComponent('urn:ietf:wg:oauth:2.0:oob'),
    
client_id:encodeURIComponent('999544234930-25c9eifdvvfrd4mnnphdl9e3r7veb3d1.apps.googleusercontent.com'),
    method: 'POST',
    muteHttpExceptions : true
  }

  Logger.log(UrlFetchApp.fetch(url, options))
  }

When I send this, it gives me an error saying that I am missing the 
required parameter grant_type, which I have specified:

{
  "error" : "invalid_request",
  "error_description" : "Required parameter is missing: grant_type"
}

Other solutions included these:
1. Ensure you are using a POST request (I am)
2. Ensure all parameters are URL encoded (they are)
3. Put the parameters in the body of the request instead of the URL (I did)

Could anyone point me in the right direction? Thank you in advance for your 
help.

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to