mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2025-12-30 16:13:33 +01:00
Account for the fact that access tokens are optional now.
This commit is contained in:
@@ -154,6 +154,8 @@ pub enum Error {
|
||||
UserError(String),
|
||||
/// A lower level IO error.
|
||||
LowLevelError(io::Error),
|
||||
/// We required an access token, but received a response that didn't contain one.
|
||||
MissingAccessToken,
|
||||
/// Other errors produced by a storage provider
|
||||
OtherError(anyhow::Error),
|
||||
}
|
||||
@@ -206,6 +208,13 @@ impl fmt::Display for Error {
|
||||
}
|
||||
Error::UserError(ref s) => s.fmt(f),
|
||||
Error::LowLevelError(ref e) => e.fmt(f),
|
||||
Error::MissingAccessToken => {
|
||||
write!(
|
||||
f,
|
||||
"Expected an access token, but received a response without one"
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
Error::OtherError(ref e) => e.fmt(f),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ impl From<TokenResponse> for TokenInfo {
|
||||
)
|
||||
.ok();
|
||||
TokenInfo {
|
||||
access_token: resp.access_token,
|
||||
access_token: Some(resp.access_token),
|
||||
refresh_token: None,
|
||||
expires_at,
|
||||
id_token: None,
|
||||
@@ -99,7 +99,8 @@ impl ServiceAccountImpersonationFlow {
|
||||
.inner_flow
|
||||
.token(hyper_client, scopes)
|
||||
.await?
|
||||
.access_token;
|
||||
.access_token
|
||||
.ok_or(Error::MissingAccessToken)?;
|
||||
|
||||
let scopes: Vec<_> = scopes.iter().map(|s| s.as_ref()).collect();
|
||||
let req_body = Request {
|
||||
|
||||
Reference in New Issue
Block a user