Remove code to strip trailing newlines for backwards compatibility.

Based on the comment in the code the justification for the change was
because old FlowDelegates used to contain newlines and changing how the
returned string from the delegate was handled would be a breaking
change. In this case it should be safe to remove the hack because we're
breaking compatibility. All users that once implemented FlowDelegate
will now need to implement InstalledFlowDelegate and uphold the new
contract which implicitly means the authcode returned should represent
the authcode and nothing more. No manipulation of the returned string
will be done.
This commit is contained in:
Glenn Griffin
2019-11-21 11:21:39 -08:00
parent 2253c60b89
commit ae2258bc7a

View File

@@ -127,16 +127,11 @@ impl InstalledFlow {
scopes,
self.flow_delegate.redirect_uri(),
);
let mut authcode = self
let authcode = self
.flow_delegate
.present_user_url(&url, true /* need code */)
.await
.map_err(Error::UserError)?;
// Partial backwards compatibility in case an implementation adds a new line
// due to previous behaviour.
if authcode.ends_with('\n') {
authcode.pop();
}
self.exchange_auth_code(&authcode, hyper_client, app_secret, None)
.await
}