Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect URL being falsely encoded for ImplicitUserTokenBuilder #159

Closed
PeakKS opened this issue Feb 19, 2025 · 3 comments
Closed

Redirect URL being falsely encoded for ImplicitUserTokenBuilder #159

PeakKS opened this issue Feb 19, 2025 · 3 comments

Comments

@PeakKS
Copy link

PeakKS commented Feb 19, 2025

The redirect URL is being encoded for ImplicitUserTokenBuilder when it should not be.

For example this code:

pub fn sign_in() {
    let client_id = ClientId::new(String::from("<clientidhere>"));
    let redirect_url = url::Url::parse("http://localhost:7777").unwrap();
    println!("{redirect_url}");
    let mut builder = ImplicitUserTokenBuilder::new(client_id, redirect_url);
    builder.add_scope(Scope::UserReadFollows);

    let (request_url, csrf_token) = builder.generate_url();
    println!("{request_url}");
    oauth2_server::spawn_oauth_listener(csrf_token);
}

Prints this:

http://localhost:7777/
https://id.twitch.tv/oauth2/authorize?response_type=token&client_id=<cliendidhere>&redirect_uri=http%3A%2F%2Flocalhost%3A7777%2F&state=KwdgFYe1bVQ7wbdL4NsomQ%3D%3D&scope=user%3Aread%3Afollows

But the URL that it should generate is this:

http://localhost:7777/
https://id.twitch.tv/oauth2/authorize?response_type=token&client_id=<cliendidhere>&redirect_uri=http://localhost:7777&state=KwdgFYe1bVQ7wbdL4NsomQ%3D%3D&scope=user%3Aread%3Afollows

TLDR should get redirect_uri=http://localhost:7777 instead of redirect_uri=http%3A%2F%2Flocalhost%3A7777%2F

@Emilgardis
Copy link
Member

Emilgardis commented Feb 19, 2025

This is a known issue, duplicate of #112

it's due to how the URL crate does this. Technically https://example.org is not an url, it's missing a path

@Emilgardis
Copy link
Member

Emilgardis commented Feb 19, 2025

also, I'd like to point you towards using DCF :3 its imo way better than implicit, it even allows refreshing the token :D

@PeakKS
Copy link
Author

PeakKS commented Feb 19, 2025

also, I'd like to point you towards using DCF :3 its imo way better than implicit, it even allows refreshing the token :D

Wow yeah that's a lot easier thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants