Add a helper for completing authentication via the command line

This commit is contained in:
Paul Woolcock
2018-08-31 07:26:03 -04:00
parent e284894d40
commit 034bd4e6d1
4 changed files with 34 additions and 17 deletions
+2 -6
View File
@@ -6,6 +6,7 @@ pub use self::elefren::prelude::*;
use std::{error::Error, io};
use self::elefren::helpers::cli;
#[cfg(feature = "toml")]
use self::elefren::helpers::toml;
@@ -34,12 +35,7 @@ pub fn register() -> Result<Mastodon, Box<Error>> {
.scopes(Scopes::all())
.website("https://github.com/pwoolcoc/elefren")
.build()?;
let url = registration.authorize_url()?;
println!("Click this link to authorize on Mastodon: {}", url);
let code = read_line("Paste the returned authorization code: ")?;
let mastodon = registration.complete(&code)?;
let mastodon = cli::authenticate(registration)?;
// Save app data for using on the next run.
toml::to_file(&*mastodon, "mastodon-data.toml")?;