_server.AuthorizationCodeReceived += _server_AuthorizationCodeReceived;
_server.ErrorReceived += _server_ErrorReceived;
_server.ImplictGrantReceived += _server_ImplictGrantReceived;
await _server.Start();
var request = new LoginRequest(_server.BaseUri, "16d40a7f986d49a3991c32934a1b4f50", LoginRequest.ResponseType.Code)
{
Scope = new List<string> { Scopes.UserModifyPlaybackState, Scopes.UserReadPlaybackState }
};
BrowserUtil.Open(request.ToUri());
}
private async Task _server_ImplictGrantReceived(object arg1, ImplictGrantResponse arg2)
{
listView1.Items.Add("Client");
}
private async Task _server_ErrorReceived(object arg1, string arg2, string? arg3)
{
listView1.Items.Add("Error");
}
private async Task _server_AuthorizationCodeReceived(object arg1, AuthorizationCodeResponse arg2)
{
await _server.Stop();
ClientConfig = SpotifyClientConfig
.CreateDefault();
listView1.Items.Add("Authenticating");
var response = await new OAuthClient(ClientConfig).RequestToken(
new AuthorizationCodeTokenRequest(
"16d40a7f986d49a3991c32934a1b4f50", "6f652f2b518243c3aecf86db25891323", arg2.Code, new Uri("http://localhost:5543/callback")
)
);
throw new Exception($"{arg2.ToJson()} {response.ToJson()}");
Client = new SpotifyClient(response.AccessToken);
listView1.Items.Add("Client");
var queue = await Client.Player.GetQueue();
foreach (var item in queue.Queue)
{
var lvi = new ListViewItem();
lvi.Tag = item;
lvi.Text = item.ToJson();
listView1.Items.Add(lvi);
}
listView1.Items.Add("received");
}`
As you can see, I try to receive an access token here to use for access to the queue, and to be able to add premium tracks to the queue.
For some reason, at Form1_load, _server.AuthorizationCodeReceived += _server_AuthorizationCodeReceived isn't raised when the authorization request has been successfull. I've tried with a different port, various browsers, even checked if the ImplicitGrantReceived event wasn't raised instead. None of the registred events do anything, at all.
Am I missing something, is the browsers I tried with, or is the library broken?
I'm curious what's going wrong.
I use Visual Studio 2022 community edition on Windows 11 latest build. I have chrome, edge and brave installed.
` private async void Form1_Load(object sender, EventArgs e) { _server = new EmbedIOAuthServer(new Uri("http://localhost:5543/callback"), 5543);
As you can see, I try to receive an access token here to use for access to the queue, and to be able to add premium tracks to the queue.
For some reason, at Form1_load, _server.AuthorizationCodeReceived += _server_AuthorizationCodeReceived isn't raised when the authorization request has been successfull. I've tried with a different port, various browsers, even checked if the ImplicitGrantReceived event wasn't raised instead. None of the registred events do anything, at all.
Am I missing something, is the browsers I tried with, or is the library broken?