public MainPage() { InitializeComponent(); _userAccountManager = new WindowsUniversalUserAccountManager(); IGrooveClient grooveClient = GrooveClientFactory.CreateGrooveClient(ApplicationClientId, ApplicationClientSecret, _userAccountManager); ErrorViewModel = new GrooveApiErrorViewModel(); MusicContentPaneViewModel = new MusicContentPaneViewModel(grooveClient, ErrorViewModel); PlayerViewModel = new PlayerViewModel(grooveClient, ErrorViewModel); UserProfileViewModel = new UserProfileViewModel(_userAccountManager, grooveClient, ErrorViewModel); }
public async Task HelpYouGetStarted() { // Start by registering an Application on the Groove API Program (see https://developer.microsoft.com/dashboard/groove) // Create a client IGrooveClient client = GrooveClientFactory.CreateGrooveClient(MicrosoftAppClientId, MicrosoftAppClientSecret); // Use null to get your current geography. // Specify a 2 letter country code (such as "US" or "DE") to force a specific country. string country = null; // Search for albums in your current geography ContentResponse searchResponse = await client.SearchAsync( MediaNamespace.music, "Foo Fighters", filter : SearchFilter.Albums, maxItems : 5, country : country); Console.WriteLine($"Found {searchResponse.Albums.TotalItemCount} albums"); foreach (Album albumResult in searchResponse.Albums.Items) { Console.WriteLine(albumResult.Name); } // List tracks in the first album Album album = searchResponse.Albums.Items[0]; ContentResponse lookupResponse = await client.LookupAsync( album.Id, extras : ExtraDetails.Tracks, country : country); // Display information about the album album = lookupResponse.Albums.Items[0]; Console.WriteLine($"Album: {album.Name} (link: {album.GetLink(ContentExtensions.LinkAction.Play)}, " + $"image: {album.GetImageUrl(800, 800)})"); foreach (Contributor contributor in album.Artists) { Artist artist = contributor.Artist; Console.WriteLine($"Artist: {artist.Name} (link: {artist.GetLink()}, image: {artist.GetImageUrl(1920, 1080)})"); } foreach (Track track in album.Tracks.Items) { Console.WriteLine($"Track: {track.TrackNumber} - {track.Name}"); } }
private async void LoginButton_Click(object sender, EventArgs e) { UserTokenManager manager = new UserTokenManager(); bool success = await manager.LoginAsync(); if (success) { _client = GrooveClientFactory.CreateGrooveClient(Secret.CLIENTID, Secret.CLIENTSECRET, manager); EnableButtons(); } else { // show error that login had a failure OutputTextBox.Text = "Login failure"; } }
public static void Setup() { //using official VK app for Windows appId and secret SimpleIoc.Default.Register(() => new Vk(appId: "3502561", clientSecret: "omvP3y2MZmpREFZJDNHd", apiVersion: "5.60", userAgent: "com.vk.wp_app/4111 (WindowsPhone_10.0.14393.0, Microsoft__RM-1090_1010)")); SimpleIoc.Default.Register(() => new LastFm(apiKey: "a012acc1e5f8a61bc7e58238ce3021d8", apiSecret: "86776d4f43a72633fb37fb28713a7798")); SimpleIoc.Default.Register(() => new Deezer(appId: "229622", secretKey: "da90d8606bf99c8e1b403a80e03aefa3")); SimpleIoc.Default.Register(() => GrooveClientFactory.CreateGrooveClient("00000000480DD98A", "czFUCiXbMxQ7M+z5ycKFPWs2W1S7TxFh")); //SimpleIoc.Default.Register(() => new SQLiteAsyncConnection(DbPath)); SimpleIoc.Default.Register <VkTracksService>(); SimpleIoc.Default.Register <VkUserService>(); SimpleIoc.Default.Register <CacheService>(); SimpleIoc.Default.Register <ImageService>(); SimpleIoc.Default.Register <DiscoveryService>(); SimpleIoc.Default.Register <MusicResolveService>(); SimpleIoc.Default.Register <ScrobblingService>(); }
static TestBase() { MicrosoftAppClientId = ConfigurationManager.AppSettings["clientid"]; MicrosoftAppClientSecret = ConfigurationManager.AppSettings["clientsecret"]; Assert.IsNotNull(MicrosoftAppClientId, "The client id should be set in App.config"); Assert.IsNotNull(MicrosoftAppClientSecret, "The client secret should be set in App.config"); Assert.IsFalse(MicrosoftAppClientSecret.Contains("%"), "The client secret should not be URL encoded"); Client = GrooveClientFactory.CreateGrooveClient( MicrosoftAppClientId, MicrosoftAppClientSecret); UserAuthenticatedClient = GrooveClientFactory.CreateGrooveClient( MicrosoftAppClientId, MicrosoftAppClientSecret, new TestUserTokenManagerFromConfigurationValue()); }
private async void LoginButton_Click(object sender, EventArgs e) { UserTokenManager manager = new UserTokenManager(); try { bool loginSuccess = await manager.LoginAsync(); if (loginSuccess) { _client = GrooveClientFactory.CreateGrooveClient(Secret.CLIENTID, Secret.CLIENTSECRET, manager); WriteOutputLine("Successfully logged in."); OnLoginSuccess(); } else { WriteOutputLine("Error while logging in"); } } catch (ConfigurationErrorsException ex) { WriteOutputLine("Could not save refresh token. Please run as admin to allow saving of refresh token, or you will have to manually authenticate with every request."); } }