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

Implement DCF (Device Code auth flow) #135

Open
Emilgardis opened this issue Dec 6, 2023 · 2 comments
Open

Implement DCF (Device Code auth flow) #135

Emilgardis opened this issue Dec 6, 2023 · 2 comments

Comments

@Emilgardis
Copy link
Member

Emilgardis commented Dec 6, 2023

We should implement this with the correct grants.

I'm a bit conflicted though about how the interface should look like. Maybe a builder like the other auth flows, but then two different methods for public or confidential type.

We also need to implement refresh tokens without client_secret. We'd have to either change

client_secret: &ClientSecret,
or provide two new functions

@bryanveloso
Copy link

I'm opting to use DCF in my desktop app and have had to use the popular oauth2 crate for it. Unfortunately, Twitch (surprise) doesn't follow the spec, which requires the 400 statuses to return the auth status in an error property. Twitch in this case returns the status in a message property which panics the crate. So I'm having to manually do a lot of this.

I'd love to have to not deal with it, but unfortunately I'm too new of a Rust dev to really contribute otherwise. I do like how painless oauth2's method of implementing DCF is though!

@Emilgardis
Copy link
Member Author

Emilgardis commented Dec 14, 2023

I think something like the following will work

let mut builder = DeviceUserTokenBuilder::new(client_id, scopes);
if confidential {
    builder.set_secret(client_secret);
}
let code = builder.exchange_device_code(client).await?;
println!("Enter {code}");
...
let token: UserToken = UserTokenbuilder.finish().await?;

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