Struct yup_oauth2::DeviceFlow [] [src]

pub struct DeviceFlow<C> {
    // some fields omitted
}

Implements the Oauth2 Device Flow It operates in two steps: * obtain a code to show to the user * (repeatedly) poll for the user to authenticate your application

Methods

impl<C> DeviceFlow<C> where C: BorrowMut<Client>
[src]

Examples

extern crate hyper;
extern crate yup_oauth2 as oauth2;
use oauth2::DeviceFlow;

let mut f = DeviceFlow::new(hyper::Client::new());

The first step involves asking the server for a code that the user can type into a field at a specified URL. It is called only once, assuming there was no connection error. Otherwise, it may be called again until you receive an Ok result.

Arguments

  • client_id & client_secret - as obtained when registering your application
  • scopes - an iterator yielding String-like objects which are URLs defining what your application is able to do. It is considered good behaviour to authenticate only once, with all scopes you will ever require. However, you can also manage multiple tokens for different scopes, if your application is providing distinct read-only and write modes. # Panics
  • If called after a successful result was returned at least once. # Examples See test-cases in source code for a more complete example.

If the first call is successful, this method may be called. As long as we are waiting for authentication, it will return Ok(None). You should call it within the interval given the previously returned PollInformation.interval field.

The operation was successful once you receive an Ok(Some(Token)) for the first time. Subsequent calls will return the previous result, which may also be an error state.

Do not call after PollError::Expired|PollError::AccessDenied was among the Err(PollError) variants as the flow will not do anything anymore. Thus in any unsuccessful case which is not PollError::HttpError, you will have to start /// over the entire flow, which requires a new instance of this type.

⚠️ Warning: We assume the caller doesn't call faster than interval and are not protected against this kind of mis-use.

Examples

See test-cases in source code for a more complete example.