Happy Saturday everyone. I am using `std.net.curl:post` to request an OAuth access token from a Google API. Initially I was getting a 400 status code back but could not tell why. I used the `verbose` option on `HTTP()` to get more details:

```D
char[] tokenResponse;
auto connection = HTTP();
connection.verbose = true;

try
{
    tokenResponse = post
    (
    tokenRequestEndpoint,
["code": incomingCode, "redirect_uri": tokenRequestRedirectUrl, "grant_type": "authorization_code", "code_verifier": to!string(codeVerifier),
     "client_id": clientId, "client_secret": clientSecret],
    connection
    );
}
catch(HTTPStatusException e)
{
writefln("Token request failed - Status code: %d - Message: %s\n", e.status, e.msg);
    return 1;
}
```

That `verbose` option gets me a detailed log but I cannot see the payload of my request nor that of the response:

```
*   Trying 172.217.165.10:443...
* TCP_NODELAY set
* Connected to www.googleapis.com (172.217.165.10) port 443 (#0)
POST /oauth2/v4/token HTTP/1.1
Host: www.googleapis.com
User-Agent: Phobos-std.net.curl/2.098 (libcurl/7.68.0)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Content-Length: 16
Content-Type: application/x-www-form-urlencoded

* We are completely uploaded and fine
* Mark bundle as not supporting multiuse
< HTTP/1.1 400 Bad Request
< Content-Type: application/json; charset=utf-8
< Vary: X-Origin
< Vary: Referer
< Date: Sat, 27 Nov 2021 14:24:45 GMT
< Server: scaffolding on HTTPServer2
< Cache-Control: private
< X-XSS-Protection: 0
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
< Accept-Ranges: none
< Vary: Origin,Accept-Encoding
< Transfer-Encoding: chunked
<
* Connection #0 to host www.googleapis.com left intact
```

Is there a way to see that information? Google's API does not seem to provide much more than a status code as to the reason for the failure.

Reply via email to