Hello 
Please forgive me in advance for my English The Google Ads API client 
library uses gRPC. However, my hosting provider does not give the option to 
install gRPC. So I have to use the REST API. I am trying to get an access 
token using the following code:

$url = "https://accounts.google.com/o/oauth2/auth";;
$arr = array(
'grant_type' => 'refresh_token', 
'refresh_token' => '***refreshtoken***', 
'client_id' => '***clientid***',
'client_secret' => '***clientsecret***',
);
$headers = array(
'Accept: application/json',
'Content-Type: application/json',
);
$post_arr=array();
foreach ($arr as $key=>$value) {
$post_arr[]=$key."=".$value;
}
$data=implode('&',$post_arr);

$handle=curl_init();
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($handle, CURLOPT_POST, true);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
$response=curl_exec($handle);
$code=curl_getinfo($handle, CURLINFO_HTTP_CODE);

In response I get error 302 and the following

<HTML>
<HEAD>
<TITLE>Moved Temporarily</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Moved Temporarily</H1>
The document has moved <A 
HREF="https://accounts.google.com/signin/oauth/error?authError=Cg9pbnZh......yIJAD&amp;client_id=332052792041-lka09bsu9g3h15em6g2jeua8v429fk95.apps.googleusercontent.com";>here</A>.
</BODY>
</HTML>

What is my mistake?

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
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 and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/ddd5ac34-41f1-4293-8efd-5f520d296febn%40googlegroups.com.
  • g... 'Вячеслав Иванов' via AdWords API and Google Ads API Forum
    • ... AdWords API and Google Ads API Forum
    • ... 'Aryeh Baker' via AdWords API and Google Ads API Forum
      • ... Google Ads API Forum Advisor
        • ... Google Ads API Forum Advisor

Reply via email to