so… first of all, I must say I just graduated from school and never worked with web requests before that so I might be missing something obvious, and if that happens, I am really sorry…
For a few hours now, I’ve been trying to connect to the Patreon API through Unity, I tried to follow another subject that was here : Accessing API through Unity
But unfortunately, this didn’t work at all for me, the WWW class being deprecated.
So the thing is that I’m trying to make a Launcher on which you could enter your credentials and login to Patreon to get informations about the money being given (How much is given)
I’ve been trying to mess around with the UnityWebRequest and ended up trying 2 differents things, here’s my code so far.
public string _ClientID;
public string _RedirectURI = “http://localhost”;
public int _Port = 8080;
private IEnumerator GetDataAsync()
//https://www.patreon.com/api/oauth2/api/current_user //https://www.patreon.com/oauth2/authorize //https://eno0ll665h0px8e.m.pipedream.net //Returns Error 403 (Forbidden) string _Request = "https://www.patreon.com/oauth2/authorize?" + "response_type=code" + "&" + "client_id=" + _ClientID + "&" + "redirect_uri=" + _RedirectURI + ":" + _Port.ToString(); UnityWebRequest _PatreonRequest = UnityWebRequest.Get(_Request); //To use with https://www.patreon.com/api/oauth2/api/current_user (Supposedly) Returns Error 401 (Unauthorized) //_PatreonRequest.SetRequestHeader("Authorization", "Bearer " + _ClientID); //To use with UnityWebRequest _PatreonRequest = new UnityWebRequest(https://www.patreon.com/oauth2/authorize); Returns Error 403 (Forbidden) //_PatreonRequest.SetRequestHeader("response-type", "code"); //_PatreonRequest.SetRequestHeader("client-id", _ClientID); //_PatreonRequest.SetRequestHeader("redirect-uri", _RedirectURI + ":" + _Port.ToString()); _PatreonRequest.SetRequestHeader("content-type", "application/x-www-form-urlencoded"); _PatreonRequest.downloadHandler = new DownloadHandlerBuffer(); _PatreonRequest.SendWebRequest(); while (!_PatreonRequest.isDone) yield return null; if (_PatreonRequest.isNetworkError || _PatreonRequest.isHttpError) Debug.Log(_PatreonRequest.error); else Debug.Log("Connected : " + _PatreonRequest.responseCode); }
So… I’d like to know if I’m doing something wrong, if that’s even possible and what possibilities I could be considering.
Thank you in advance for your answers !