static UnityWebRequest generateOrUpdateUnityClient(string projectGuid, string method, UnityClientInfo unityClientInfo, string callbackUrl) { UnityChannel channel = new UnityChannel(); channel.projectGuid = projectGuid; channel.callbackUrl = callbackUrl; if (tps != null && tps.Length > 0 && tps[0] != null && !String.IsNullOrEmpty(tps[0].appId)) { channel.thirdPartySettings = tps; for (int i = 0; i < channel.thirdPartySettings.Length; i++) { if (channel.thirdPartySettings[i].appType.Equals("gstore")) { channel.thirdPartySettings[i].appKey = null; channel.thirdPartySettings[i].appSecret = null; } if (channel.thirdPartySettings[i].appType.Equals("xiaomi")) { channel.thirdPartySettings[i].extraProperties = null; } } } // set necessary client post data UnityClient client = new UnityClient(); client.client_name = projectGuid; client.scopes.Add("identity"); client.channel = channel; string api = null; if (method.Equals(UnityWebRequest.kHttpVerbPOST, StringComparison.InvariantCultureIgnoreCase)) { api = "/v1/oauth2/user-clients"; } else if (method.Equals(UnityWebRequest.kHttpVerbPUT, StringComparison.InvariantCultureIgnoreCase)) { // if client is not generated or loaded, directly ignore update if (unityClientInfo.ClientId == null) { Debug.LogError("Please get/generate Unity Client first."); loaded = false; return(null); } if (updateRev == null) { Debug.LogError("Please get/generate Unity Client first."); loaded = false; return(null); } client.rev = updateRev; if (orgId == null) { Debug.LogError("Please get/generate Unity Client first."); loaded = false; return(null); } client.owner = orgId; client.ownerType = "ORGANIZATION"; api = "/v1/oauth2/user-clients/" + unityClientInfo.ClientId; } else { return(null); } string token = tokenInfo.access_token; return(asyncRequest(method, url, api, token, client)); }
public static UnityWebRequest UpdateUnityClient(string projectGuid, UnityClientInfo unityClientInfo, string callbackUrl) { return(generateOrUpdateUnityClient(projectGuid, UnityWebRequest.kHttpVerbPUT, unityClientInfo, callbackUrl)); }