From 4e5547a2b68c10a6c1101544f7032093df1b1d9e Mon Sep 17 00:00:00 2001 From: Jader Dias <52470+JaderDias@users.noreply.github.com> Date: Sun, 16 Jun 2024 22:34:31 +0200 Subject: [PATCH] redirect_uri=localhost instead of 127.0.0.1 Facebook GraphAPI doesn't support 127.0.0.1 as redirect_uri --- src/installed.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/installed.rs b/src/installed.rs index 2a472bfb2..42e17d9af 100644 --- a/src/installed.rs +++ b/src/installed.rs @@ -20,6 +20,7 @@ use tokio::io::{AsyncRead, AsyncWrite}; use tokio::sync::oneshot; use tower_service::Service; use url::form_urlencoded; +use url::quirks::port; const QUERY_SET: AsciiSet = CONTROLS.add(b' ').add(b'"').add(b'#').add(b'<').add(b'>'); @@ -204,7 +205,7 @@ impl InstalledFlow { // by certain providers. let redirect_uri: Cow = match self.flow_delegate.redirect_uri() { Some(uri) => uri.into(), - None => format!("http://{}", server_addr).into(), + None => format!("http://localhost:{}", server_addr.port()).into(), }; let url = build_authentication_request_url( &app_secret.auth_uri, @@ -255,7 +256,7 @@ impl InstalledFlow { use std::borrow::Cow; let redirect_uri: Cow = match (custom_redirect_uri, server_addr) { (Some(uri), _) => uri.into(), - (None, Some(addr)) => format!("http://{}", addr).into(), + (None, Some(addr)) => format!("http://localhost:{}", addr.port()).into(), (None, None) => OOB_REDIRECT_URI.into(), };