override protected void Awake() { base.Awake(); m_Identity = App.GoogleIdentity; OAuth2Identity.ProfileUpdated += OnProfileUpdated; RefreshButtons(); }
public DriveAccess(OAuth2Identity googleIdentity, GoogleUserSettings googleUserSettings) { m_GoogleIdentity = googleIdentity; m_GoogleUserSettings = googleUserSettings; m_DeviceId = GetDeviceId(); m_GoogleIdentity.OnSuccessfulAuthorization += OnGoogleLogin; m_GoogleIdentity.OnLogout += OnGoogleLogout; }
void OnProfileUpdated(OAuth2Identity _) { // If we're currently telling the user to take of the headset to signin, // and they've done so correctly, switch back to the accounts view. if (m_CurrentMode == Mode.TakeOffHeadset) { UpdateMode(Mode.Accounts); } RefreshObjects(); }
public void TestSetImageUrlOptions() { // Just a quick test that SetImageUrl Assert.AreEqual( OAuth2Identity.SetImageUrlOptions( "https://lh3.googleusercontent.com/a-/AN66SAy7y9N4Do-folxEcPjtglaoHtam6THlfn8wk8aF=s100"), "https://lh3.googleusercontent.com/a-/AN66SAy7y9N4Do-folxEcPjtglaoHtam6THlfn8wk8aF=s128-c-k-no-rj"); Assert.AreEqual( OAuth2Identity.SetImageUrlOptions( "https://lh3.googleusercontent.com/a-/AN66SAy7y9N4Do-folxEcPjtglaoHtam6THlfn8wk8aF"), "https://lh3.googleusercontent.com/a-/AN66SAy7y9N4Do-folxEcPjtglaoHtam6THlfn8wk8aF=s128-c-k-no-rj"); }
// identity may be null, in which case no authentication takes place public WebRequest(string uri, OAuth2Identity identity, string method = UnityWebRequest.kHttpVerbGET, bool compress = false) { if (string.IsNullOrEmpty(uri)) { throw new ArgumentException("uri"); } if (!kEnableHttpCompression) { compress = false; } m_Method = method; m_Compressed = compress; m_Uri = uri; m_Identity = identity; }
void OnProfileUpdated(OAuth2Identity _) { RefreshObjects(); }
private void OnProfileUpdated(OAuth2Identity _) { RefreshButtons(); }
public SketchfabService(OAuth2Identity identity) { m_identity = identity; }
void OnProfileUpdated(OAuth2Identity _) { RefreshFetchCoroutines(); }
public GoogleUserSettings(OAuth2Identity googleIdentity) { m_GoogleIdentity = googleIdentity; m_GoogleIdentity.OnLogout += GoogleLoggedOut; }
// Initiates the contact with Poly. public IEnumerator <Null> GetAssetCoroutine() { OAuth2Identity identity = null; if (!m_URI.StartsWith(VrAssetService.ApiHost)) { m_Asset.SetRootElement(UnityWebRequest.EscapeURL(m_URI), m_URI); } else { identity = App.GoogleIdentity; if (string.IsNullOrEmpty(App.Config.GoogleSecrets?.ApiKey)) { IsCanceled = true; yield break; } m_Ready = false; WebRequest initialRequest = new WebRequest(m_URI, App.GoogleIdentity, UnityWebRequest.kHttpVerbGET); using (var cr = initialRequest.SendAsync().AsIeNull()) { while (!initialRequest.Done) { try { cr.MoveNext(); } catch (VrAssetServiceException e) { Debug.LogException(e); IsCanceled = true; yield break; } yield return(cr.Current); } } // Deserialize request string in to an Asset class. MemoryStream memStream = new MemoryStream(Encoding.UTF8.GetBytes(initialRequest.Result)); using (var jsonReader = new JsonTextReader(new StreamReader(memStream))) { Future <JObject> f = new Future <JObject>(() => JObject.Parse(initialRequest.Result)); JObject json; while (!f.TryGetResult(out json)) { yield return(null); } if (json.Count == 0) { Debug.LogErrorFormat("Failed to deserialize response for {0}", m_URI); yield break; } // Find the asset by looking through the format list for the specified type. VrAssetFormat requestedType = m_Asset.DesiredType; while (true) { var format = json["formats"]?.FirstOrDefault(x => x["formatType"]?.ToString() == requestedType.ToString()); if (format != null) { string internalRootFilePath = format["root"]?["relativePath"].ToString(); // If we successfully get a gltf2 format file, internally change the extension to // "gltf2" so that the cache knows that it is a gltf2 file. if (requestedType == VrAssetFormat.GLTF2) { internalRootFilePath = Path.ChangeExtension(internalRootFilePath, "gltf2"); } // Get root element info. m_Asset.SetRootElement( internalRootFilePath, format["root"]?["url"].ToString()); // Get all resource infos. There may be zero. foreach (var r in format["resources"]) { string path = r["relativePath"].ToString(); m_Asset.AddResourceElement(path, r["url"].ToString()); // The root element should be the only gltf file. Debug.Assert(!path.EndsWith(".gltf") && !path.EndsWith(".gltf2"), string.Format("Found extra gltf resource: {0}", path)); } break; } else { // We asked for an asset in a format that it doesn't have. // In some cases, we should look for a different format as backup. if (requestedType == VrAssetFormat.GLTF2) { requestedType = VrAssetFormat.GLTF; } else { // In other cases, we should fail and get out. Debug.LogErrorFormat("Can't download {0} in {1} format.", m_Asset.Id, m_Asset.DesiredType); yield break; } } } } } // Download root asset. var request = new WebRequest(m_Asset.RootDataURL, identity); using (var cr = request.SendAsync().AsIeNull()) { while (!request.Done) { try { cr.MoveNext(); } catch (VrAssetServiceException e) { Debug.LogErrorFormat("Error downloading {0} at {1}\n{2}", m_Asset.Id, m_Asset.RootDataURL, e); yield break; } yield return(cr.Current); } } m_Asset.CopyBytesToRootElement(request.ResultBytes); // Download all resource assets. foreach (var e in m_Asset.ResourceElements) { request = new WebRequest(e.dataURL, App.GoogleIdentity); using (var cr = request.SendAsync().AsIeNull()) { while (!request.Done) { try { cr.MoveNext(); } catch (VrAssetServiceException ex) { Debug.LogErrorFormat("Error downloading {0} at {1}\n{2}", m_Asset.Id, m_Asset.RootDataURL, ex); e.assetBytes = null; yield break; } yield return(cr.Current); } } e.assetBytes = request.ResultBytes; } m_Ready = true; }