diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-11-27 11:46:57 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-11-27 11:46:57 -0500 |
commit | fd449e52fb9a00cff2006e927ac97c386a8484ca (patch) | |
tree | e0e83f46e36e435e6e3bfd4b1aac550fc26feb18 | |
parent | 3e554af64a8cecdcba8e39e6e07be1a2d9c4d338 (diff) | |
download | teleterm-fd449e52fb9a00cff2006e927ac97c386a8484ca.tar.gz teleterm-fd449e52fb9a00cff2006e927ac97c386a8484ca.zip |
actually, the token response needs to send both tokens
the server needs the access token to use for the current login process,
but it'll also need to store the refresh token so that it doesn't need
to re-login afterwards
-rw-r--r-- | teleterm/src/protocol.rs | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/teleterm/src/protocol.rs b/teleterm/src/protocol.rs index bbd14d2..cb95947 100644 --- a/teleterm/src/protocol.rs +++ b/teleterm/src/protocol.rs @@ -316,7 +316,8 @@ pub enum Message { code: String, }, OauthResponseToken { - token: String, + access_token: String, + refresh_token: String, }, } @@ -395,9 +396,13 @@ impl Message { } } - pub fn oauth_response_token(token: &str) -> Self { + pub fn oauth_response_token( + access_token: &str, + refresh_token: &str, + ) -> Self { Self::OauthResponseToken { - token: token.to_string(), + access_token: access_token.to_string(), + refresh_token: refresh_token.to_string(), } } @@ -651,8 +656,12 @@ impl From<&Message> for Packet { Message::OauthResponseCode { code } => { write_str(code, &mut data); } - Message::OauthResponseToken { token } => { - write_str(token, &mut data); + Message::OauthResponseToken { + access_token, + refresh_token, + } => { + write_str(access_token, &mut data); + write_str(refresh_token, &mut data); } } @@ -846,9 +855,16 @@ impl std::convert::TryFrom<Packet> for Message { (Self::OauthResponseCode { code }, data) } MessageType::OauthResponseToken => { - let (token, data) = read_str(data)?; + let (access_token, data) = read_str(data)?; + let (refresh_token, data) = read_str(data)?; - (Self::OauthResponseToken { token }, data) + ( + Self::OauthResponseToken { + access_token, + refresh_token, + }, + data, + ) } }; |