fix(API): adapt to changed yup-oauth2 API

The latter changed a lot, to the better, and we handle the new
return types accordingly.

Related to #74
This commit is contained in:
Sebastian Thiel
2015-04-23 17:07:28 +02:00
parent 797f289886
commit e523ddb6ec
3 changed files with 46 additions and 26 deletions

View File

@@ -665,16 +665,20 @@ else {
loop {
% if default_scope:
let mut token = ${auth_call}.token(self.${api.properties.scopes}.keys());
if token.is_none() {
token = dlg.token();
}
if token.is_none() {
${delegate_finish}(false);
return Err(Error::MissingToken)
}
let token = match ${auth_call}.token(self.${api.properties.scopes}.keys()) {
Ok(token) => token,
Err(err) => {
match dlg.token(&*err) {
Some(token) => token,
None => {
${delegate_finish}(false);
return Err(Error::MissingToken(err))
}
}
}
};
let auth_header = Authorization(oauth2::Scheme { token_type: oauth2::TokenType::Bearer,
access_token: token.unwrap().access_token });
access_token: token.access_token });
% endif
% if request_value:
request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();