401 Unauthorized Error on Identity GET

That seems to have done the trick, after getting everything standardized for V2 it’s giving me the data I want. However, after specifying some resources it doesn’t seem to like the way I tried to encode my GET:

$ch = curl_init();


curl_setopt($ch, CURLOPT_URL, 'https://www.patreon.com/api/oauth2/v2/identity?fields[User]=about,first_name,last_name,vanity,created');
$headers = ['Content-Type: application/x-www-form-urlencoded', "Authorization: Bearer " . $_SESSION["access_token"]];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

//get response from API
$apiResponseMemberData = curl_exec($ch);

It’s returning an error complaining about the square brackets in my V2 resource request saying “Please ensure the request/response body is x-www-form-urlencoded.”, though as far as I know I’ve got it set in the header there.

Again, sorry for the rookie questions, finding the right direction to go in isn’t easy without the right feedback.

EDIT: Scratch that, the answer supplied in this thread gave me a usable solution. Thanks again!

1 Like