/// <summary> /// Uses a username and password to access the Fizzyo API and load in the users access token and user Id /// This is currently incomplete as it does not use Windows live authorization /// </summary> private LoginReturnType PostAuthentication(string username, string password) { string postAuth = "https://api.fizzyo-ucl.co.uk/api/v1/auth/test-token"; WWWForm form = new WWWForm(); form.AddField("username", username); form.AddField("password", password); WWW sendPostAuth = new WWW(postAuth, form); while (!sendPostAuth.isDone) { } if (sendPostAuth.error != null) { return(LoginReturnType.INCORRECT); } AllUserData allData = JsonUtility.FromJson <AllUserData>(sendPostAuth.text); UserID = allData.user.id; AccessToken = allData.accessToken; return(LoginReturnType.SUCCESS); }
/// <summary> /// Uses a username and password to access the Fizzyo API and load in the users access token and user Id /// This is currently incomplete as it does not use Windows live authorization /// </summary> private LoginReturnType PostAuthentication(string username, string password) { Dictionary <string, string> formData = new Dictionary <string, string>(); formData.Add("username", username); formData.Add("password", password); var webRequest = FizzyoNetworking.PostWebRequest(FizzyoNetworking.ApiEndpoint + "auth/test-token", formData); webRequest.SendWebRequest(); while (!webRequest.isDone) { } if (webRequest.error != null) { return(LoginReturnType.INCORRECT); } AllUserData allData = JsonUtility.FromJson <AllUserData>(webRequest.downloadHandler.text); UserID = allData.user.id; AccessToken = allData.accessToken; LoggedIn = true; return(LoginReturnType.SUCCESS); }