public async Task TestRefreshToken() { var initial = await SoundCloudOAuth.FromClientCredentials(Settings.ClientId, Settings.ClientSecret); // Act var credentials = await SoundCloudOAuth.FromRefreshToken(Settings.ClientId, Settings.ClientSecret, initial.RefreshToken); // Assert Assert.That(credentials.AccessToken, Is.Not.Null); }
private static async Task Main() { Console.Write("ClientId: "); var clientId = Console.ReadLine().Trim(); Console.Write("ClientSecret: "); var clientSecret = Console.ReadLine().Trim(); Console.Write("Username: "******"Password: "******"AccessToken: {client.AuthInfo.AccessToken}"); Console.WriteLine($"ClientId: {client.AuthInfo.ClientId}"); var tracks = await client.Me.GetTracksAsync(10); if (tracks.Any()) { Console.WriteLine(); Console.WriteLine("Your latest Tracks:"); foreach (var track in tracks) { Console.WriteLine(track.Title); } } else { Console.WriteLine(); Console.WriteLine("You don't have any tracks"); } } }
public async void InitializeUser(string login, string password) { if (!string.IsNullOrWhiteSpace(login) && !string.IsNullOrWhiteSpace(password)) { try { var auth = await SoundCloudOAuth.FromPassword(clientId, clientSecret, login, password); _client = SoundCloud.Api.SoundCloudClient.CreateAuthorized(auth.AccessToken); mainWindow = new MainWindow(_client); mainWindow.Show(); } catch (Exception e) { MessageBox.Show("Invalid credentials: " + e.Message); } } else { ErrorWindow errorWindow = new ErrorWindow(); errorWindow.Show(); } }