[[ TOKEN, DOMAIN1, and DOMAIN2 are redactions --requinix ]]
Hi, I have a piece of code that I can execute with bash curl without problem:
mac70:gsuite_automate ted.chou$ curl -H "Authorization: OAuth TOKEN" https://apps-apis.google.com/a/feeds/domain/2.0/DOMAIN1/sso/general -v
* Trying 64.233.187.118...
* TCP_NODELAY set
* Connected to apps-apis.google.com (64.233.187.118) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.google.com
* Server certificate: Google Internet Authority G2
* Server certificate: GeoTrust Global CA
> GET /a/feeds/domain/2.0/DOMAIN1/sso/general HTTP/1.1
> Host: apps-apis.google.com
> User-Agent: curl/7.51.0
> Accept: */*
> Authorization: OAuth TOKEN
>
< HTTP/1.1 200 OK
< Content-Type: application/atom+xml; charset=UTF-8
< Expires: Tue, 24 Jan 2017 13:20:21 GMT
< Date: Tue, 24 Jan 2017 13:20:21 GMT
< Cache-Control: private, max-age=0, must-revalidate, no-transform
< Vary: Accept, X-GData-Authorization, GData-Version
< GData-Version: 1.0
< Last-Modified: Tue, 24 Jan 2017 13:20:21 GMT
< Transfer-Encoding: chunked
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< Server: GSE
< Alt-Svc: quic=":443"; ma=2592000; v="35,34"
<
* Curl_http_done: called premature == 0
* Connection #0 to host apps-apis.google.com left intact
<?xml version='1.0' encoding='UTF-8'?><entry xmlns='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'><id>https://apps-apis.google.com/a/feeds/domain/2.0/DOMAIN1/sso/general</id><updated>2017-01-24T13:20:21.003Z</updated><link rel='self' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/domain/2.0/DOMAIN1/sso/general'/><link rel='edit' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/domain/2.0/DOMAIN1/sso/general'/><apps:property name='enableSSO' value='true'/><apps:property name='changePasswordUri' value='https://DOMAIN2/sso/DOMAIN1/login'/><apps:property name='useDomainSpecificIssuer' value='true'/><apps:property name='samlLogoutUri' value='https://DOMAIN2/sso/DOMAIN1/logout'/><apps:property name='ssoWhitelist' value=''/><apps:property name='samlSignonUri' value='https://DOMAIN2/sso/DOMAIN1/login'/></entry>mac70:gsuite_automate ted.chou$
But I can't seem to reproduce it with the curl in PHP:
$crl = curl_init();
$headr = array();
$headr[] = 'Content-length: 0';
$headr[] = 'Content-type: application/json';
$headr[] = 'Authorization: OAuth ' . $access_token;
curl_setopt($crl, CURLOPT_URL, 'https://apps-apis.google.com/a/feeds/domain/2.0/DOMAIN1/sso/general');
curl_setopt($crl, CURLOPT_HEADER, true);
curl_setopt($crl, CURLOPT_HTTPHEADER, $headr);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($crl, CURLOPT_POST, false);
curl_setopt($crl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($crl, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($crl);
curl_close($crl);
echo json_decode($result);