summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorPaul Woolcock <paul@woolcock.us>2018-08-31 05:57:59 -0400
committerPaul Woolcock <paul@woolcock.us>2018-08-31 07:26:03 -0400
commit034bd4e6d107f5a48f560327cc2800cb41995f13 (patch)
treee17fd8b3204290a8e3fdc441c9665073d48a8ca7 /examples
parente284894d40e206adf8089482e340d7a9d0046d79 (diff)
Add a helper for completing authentication via the command line
Diffstat (limited to 'examples')
-rw-r--r--examples/register.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/examples/register.rs b/examples/register.rs
index 7b581ee..d6a2275 100644
--- a/examples/register.rs
+++ b/examples/register.rs
@@ -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")?;