[−][src]Struct elefren::registration::Registered
Represents the state of the auth flow when the app has been registered but the user is not authenticated
Methods
impl Registered<HttpSender>
[src]
pub fn from_parts(
base: &str,
client_id: &str,
client_secret: &str,
redirect: &str,
scopes: Scopes,
force_login: bool
) -> Registered<HttpSender>
[src]
base: &str,
client_id: &str,
client_secret: &str,
redirect: &str,
scopes: Scopes,
force_login: bool
) -> Registered<HttpSender>
Skip having to retrieve the client id and secret from the server by
creating a Registered
struct directly
Example
use elefren::{prelude::*, registration::Registered}; let registration = Registered::from_parts( "https://example.com", "the-client-id", "the-client-secret", "https://example.com/redirect", Scopes::read_all(), false, ); let url = registration.authorize_url()?; // Here you now need to open the url in the browser // And handle a the redirect url coming back with the code. let code = String::from("RETURNED_FROM_BROWSER"); let mastodon = registration.complete(&code)?; println!("{:?}", mastodon.get_home_timeline()?.initial_items);
impl<H: HttpSend> Registered<H>
[src]
pub fn into_parts(self) -> (String, String, String, String, Scopes, bool)
[src]
Returns the parts of the Registered
struct that can be used to
recreate another Registered
struct
Example
use elefren::{prelude::*, registration::Registered}; let origbase = "https://example.social"; let origclient_id = "some-client_id"; let origclient_secret = "some-client-secret"; let origredirect = "https://example.social/redirect"; let origscopes = Scopes::all(); let origforce_login = false; let registered = Registered::from_parts( origbase, origclient_id, origclient_secret, origredirect, origscopes.clone(), origforce_login, ); let (base, client_id, client_secret, redirect, scopes, force_login) = registered.into_parts(); assert_eq!(origbase, &base); assert_eq!(origclient_id, &client_id); assert_eq!(origclient_secret, &client_secret); assert_eq!(origredirect, &redirect); assert_eq!(origscopes, scopes); assert_eq!(origforce_login, force_login);
pub fn authorize_url(&self) -> Result<String>
[src]
Returns the full url needed for authorisation. This needs to be opened in a browser.
pub fn complete(&self, code: &str) -> Result<Mastodon<H>>
[src]
Create an access token from the client id, client secret, and code provided by the authorisation url.
Trait Implementations
impl<H: Clone + HttpSend> Clone for Registered<H>
[src]
fn clone(&self) -> Registered<H>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<H: Debug + HttpSend> Debug for Registered<H>
[src]
Auto Trait Implementations
impl<H> Send for Registered<H> where
H: Send,
H: Send,
impl<H> Sync for Registered<H> where
H: Sync,
H: Sync,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Erased for T
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,