I make some soft on Unity to our partners. They have their own platform with oauth2 authorization from thier site. I need to realize this logic: Step 1: post to server on auth end-point client_id, redirect_uri, response_type, scope. Step 2: user must authorize in browser with login and pass which are using to enter to their site Step 3: server give me code on redirect uri like this "https://localhost:port/?code="code"", Step 4: I take this code and send to token end-point new form with this code
Trouble is with open tab in browser where user can auth (Step 2) and then go to redirect (Step 3). I tried to Application.OpenURL(www.url);, but after user's auth I see in browser user's private area
I wrote this code, in Debug I have html code of needed page
void Start()
{
client_id = "<CLIENTID>";
client_secret = "<CLIENTSECRET>";
redirect_uri = "https://localhost:<PORT>";
StartCoroutine(SendAuthRequest());
}
IEnumerator SendAuthRequest()
{
path = "http://<URL>/connect/authorize";
WWWForm form = new WWWForm();
form.AddField("client_id", client_id);
//form.AddField("client_secret", client_secret);
form.AddField("grant_type", "authorization_code");
form.AddField("redirect_uri", redirect_uri);
form.AddField("response_type", "code");
form.AddField("scope", "api");
WWW wwwRequest = new WWW(path, form.data);
//UnityWebRequest www = UnityWebRequest.Post(path, form);
yield return wwwRequest;
Debug.Log(wwwRequest.text);