mirror of
https://github.com/librespot-org/librespot.git
synced 2024-11-08 16:45:43 +00:00
facebook: Use a random, OS-assigned port instead of hardcoded 8001.
This commit is contained in:
parent
03634e0149
commit
a7559787df
2 changed files with 8 additions and 4 deletions
|
@ -64,7 +64,7 @@ in their browser, where CSRF is a random token, and PORT is the HTTPS server's p
|
||||||
This will redirect to Facebook, where the user must login and authorize Spotify, and
|
This will redirect to Facebook, where the user must login and authorize Spotify, and
|
||||||
finally make a GET request to
|
finally make a GET request to
|
||||||
`https://login.spotilocal.com:PORT/login/facebook_login_sso.json?csrf=CSRF&access_token=TOKEN`,
|
`https://login.spotilocal.com:PORT/login/facebook_login_sso.json?csrf=CSRF&access_token=TOKEN`,
|
||||||
where CSRF is the same string sent earlier, and TOKEN is the facebook authentication token.
|
where PORT and CSRF are the same as sent earlier, and TOKEN is the facebook authentication token.
|
||||||
|
|
||||||
Since `login.spotilocal.com` resolves the 127.0.0.1, the request is received by the client.
|
Since `login.spotilocal.com` resolves the 127.0.0.1, the request is received by the client.
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use hyper;
|
use hyper;
|
||||||
use hyper::net::Openssl;
|
use hyper::net::Openssl;
|
||||||
|
use hyper::net::NetworkListener;
|
||||||
use hyper::server::Request;
|
use hyper::server::Request;
|
||||||
use hyper::server::Response;
|
use hyper::server::Response;
|
||||||
use hyper::uri::RequestUri;
|
use hyper::uri::RequestUri;
|
||||||
|
@ -93,12 +94,15 @@ pub fn facebook_login() -> Result<Credentials, ()> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let ssl = spotilocal_ssl_context().unwrap();
|
let ssl = spotilocal_ssl_context().unwrap();
|
||||||
let mut server = hyper::Server::https("127.0.0.1:8001", ssl).unwrap().handle(handler).unwrap();
|
|
||||||
|
let mut listener = hyper::net::HttpsListener::new("127.0.0.1:0", ssl).unwrap();
|
||||||
|
let port = listener.local_addr().unwrap().port();
|
||||||
|
|
||||||
|
let mut server = hyper::Server::new(listener).handle(handler).unwrap();
|
||||||
|
|
||||||
println!("Logging in using Facebook, please visit https://login.spotify.com/login-facebook-sso/?csrf={}&port={} in your browser.",
|
println!("Logging in using Facebook, please visit https://login.spotify.com/login-facebook-sso/?csrf={}&port={} in your browser.",
|
||||||
csrf, 8001);
|
csrf, port);
|
||||||
|
|
||||||
//a2c27234068bbe05d22c1b930b3bc2f5
|
|
||||||
let token = rx.recv().unwrap();
|
let token = rx.recv().unwrap();
|
||||||
let user_id = facebook_get_me_id(&token).unwrap();
|
let user_id = facebook_get_me_id(&token).unwrap();
|
||||||
let cred = Credentials {
|
let cred = Credentials {
|
||||||
|
|
Loading…
Reference in a new issue