Schaken Posted September 8, 2022 Posted September 8, 2022 (edited) hello. I cannot seem to solve this dilemma. I have been all over the internet for a solid 3 days trying to figure this out. I went to Microsoft to get just the basic format of what an OAuth URL should look like. I can manually type it all out into my browser and it will take me to the Authentication login screen on my site, So honestly, I'm pretty proud there. But when I call it from my app it is not doing anything. I am using Unity by the way. The idea here is on my app people can click a "Login" button, and it should take them to my site to login and send back a token which i will store on their PC. public void test() { StartCoroutine(GetAccessTokenA()); } private static IEnumerator GetAccessTokenA() { string uri = "http://localhost:8080/callback"; string Client_Secret = "1234567890"; string Client_ID = "abcdefghijkl"; string url = "https://XXXXXXXXX.com/oauth/authorize/"; string url2 = "https://XXXXXXXXX.com/oauth/token/"; string Scope = "files"; string SEND = url+"?client_id="+Client_ID+"&response_type=code&state="+Client_Secret+"&redirect_uri="+uri+"&scope="+Scope; Dictionary<string, string> content = new Dictionary<string, string>(); //Fill key and value content.Add("grant_type", "client_credentials"); content.Add("client_id", Client_ID); content.Add("client_secret", Client_Secret); UnityWebRequest www = UnityWebRequest.Get(SEND); //Send request yield return www.Send(); if (!www.isNetworkError) { string resultContent = www.downloadHandler.text; TokenClassName json = JsonUtility.FromJson<TokenClassName>(resultContent); Debug.Log("Success: "+json.access_token); } else { Debug.Log("failed"); } } In the end I guess I'm wondering why I'm not opening in a new window, and then if I have the rest of this correct. I apologize if this is a really poor way of doing this, I am just now learning C#. Edited September 8, 2022 by Schaken
Recommended Posts