public async static Task <ProviderInfo> GetCloudProviderAsync(CloudProviders cp) { ICloudStore cs = null; if (!providers.ContainsKey(cp)) { ProviderInfo newProvider = null; switch (cp) { case CloudProviders.OneDrive: cs = CloudStoreFactory.CreateCloudStore(CloudStorage.CloudProviders.OneDrive); Dictionary <string, object> onedriveparams = new Dictionary <string, object>(); onedriveparams[CloudParams.ClientID.ToString()] = "7ba22c7f-29be-4dc7-a274-4209fe0b8b72"; onedriveparams[CloudParams.UIParent.ToString()] = App.UiParent; if (cs.Initialize(onedriveparams)) { bool worked = await cs.AuthenticateAsync(); if (worked) { newProvider = new ProviderInfo(cp, cs); } } break; case CloudProviders.GoogleDrive: cs = CloudStoreFactory.CreateCloudStore(CloudStorage.CloudProviders.GoogleDrive); Dictionary <string, object> googledriveparams = new Dictionary <string, object>(); googledriveparams[CloudParams.ClientID.ToString()] = GetGoogleClientID(); // 133589155347-gj93njepme6jp96nh1erjmdi4q4c7d9k.apps.googleusercontent.com // 133589155347-2he14os3etg7evt97pcu5jil1udh1klk.apps.googleusercontent.com googledriveparams[CloudParams.RedirectURL.ToString()] = GetGoogleAuthRedirect(); googledriveparams[CloudParams.AppName.ToString()] = "MyMixes"; googledriveparams[CloudParams.UIParent.ToString()] = App.UiParent; googledriveparams[CloudParams.GoogleToken.ToString()] = null; if (cs.Initialize(googledriveparams)) { bool worked = await cs.AuthenticateAsync(); AuthenticationState.Authenticator = cs.GetAuthenticator(); bool authCompletWorked = await cs.CompleteAuthenticateAsync(AuthenticationState.Authenticator); if (authCompletWorked) { newProvider = new ProviderInfo(cp, cs); } } break; default: return(null); } if (newProvider != null) { providers[cp] = newProvider; return(newProvider); } } else { return(providers[cp]); } return(null); }
public ProviderInfo(CloudProviders cp, ICloudStore cs) { this.cs = cs; this.CloudProvider = cp; }