I'm currently trying to develop a music recommendation system with the spotify_rs crate and I can't help but be confused as to how I should redirect the user to the generated URL from AuthCodeClient::new
in order get the auth code and CSRF token.
(For context I'm using Actix-Web)
In an attempt to follow as stated in the docs, I made two request handlers: one that I assumed that requests authorization to access data and the other which handles the callback request to my redirect_uri
. Moreover, I also created a middleware which would handle the request to redirect_uri
to get the query parameters - code and state - of the URL.
Here's the code of the request handler which I assumed sends the authorization request via AuthCodeClient::new()
:
dotenv().ok();
let client_id = std::env::var("CLIENT_ID").expect("CLIENT_ID must be set");
let client_secret = std::env::var("CLIENT_SECRET").expect("CLIENT_SECRET must be set");
let redirect_url = RedirectUrl::new("https://localhost:8080/".to_owned()).unwrap();
let auto_refresh = true;
let scopes = vec!["user-top-read"];
let auth_code_flow = AuthCodeFlow::new(client_id, client_secret, scopes);
let (client, url) = AuthCodeClient::new(auth_code_flow, redirect_url, auto_refresh);
However, unfortunately, upon running the code I realized that the middleware did not receive any query parameters.
Is it that AuthCodeClient::new()
doesn't actually send the authorization request, and if not how do I actually approach all this? I've been working on it for a couple hours but I can't seem to get around it. Would be grateful for any help. Thanks in advance!