|
|
@@ -158,57 +158,65 @@ impl ZeroIDC {
|
|
|
.request(http_client);
|
|
|
|
|
|
res
|
|
|
-
|
|
|
});
|
|
|
|
|
|
if let Some(res) = token_response {
|
|
|
- if let Ok(res) = res {
|
|
|
- let id_token = res.id_token();
|
|
|
-
|
|
|
- if let Some(id_token) = id_token {
|
|
|
- let params = [("id_token", id_token.to_string()),("state", "refresh".to_string())];
|
|
|
- let client = reqwest::blocking::Client::new();
|
|
|
- let r = client.post((*inner_local.lock().unwrap()).auth_endpoint.clone())
|
|
|
- .form(¶ms)
|
|
|
- .send();
|
|
|
-
|
|
|
- match r {
|
|
|
- Ok(r) => {
|
|
|
- if r.status().is_success() {
|
|
|
- println!("hit url: {}", r.url().as_str());
|
|
|
- println!("status: {}", r.status());
|
|
|
-
|
|
|
-
|
|
|
- let access_token = res.access_token();
|
|
|
- let at = access_token.secret();
|
|
|
- let exp = dangerous_insecure_decode::<Exp>(&at);
|
|
|
-
|
|
|
- if let Ok(e) = exp {
|
|
|
- (*inner_local.lock().unwrap()).exp_time = e.claims.exp
|
|
|
+ match res {
|
|
|
+ Ok(res) => {
|
|
|
+ match res.id_token() {
|
|
|
+ Some(id_token) => {
|
|
|
+
|
|
|
+ let params = [("id_token", id_token.to_string()),("state", "refresh".to_string())];
|
|
|
+ let client = reqwest::blocking::Client::new();
|
|
|
+ let r = client.post((*inner_local.lock().unwrap()).auth_endpoint.clone())
|
|
|
+ .form(¶ms)
|
|
|
+ .send();
|
|
|
+
|
|
|
+ match r {
|
|
|
+ Ok(r) => {
|
|
|
+ if r.status().is_success() {
|
|
|
+ println!("hit url: {}", r.url().as_str());
|
|
|
+ println!("status: {}", r.status());
|
|
|
+
|
|
|
+
|
|
|
+ let access_token = res.access_token();
|
|
|
+ let at = access_token.secret();
|
|
|
+ let exp = dangerous_insecure_decode::<Exp>(&at);
|
|
|
+
|
|
|
+ if let Ok(e) = exp {
|
|
|
+ (*inner_local.lock().unwrap()).exp_time = e.claims.exp
|
|
|
+ }
|
|
|
+
|
|
|
+ (*inner_local.lock().unwrap()).access_token = Some(access_token.clone());
|
|
|
+ if let Some(t) = res.refresh_token() {
|
|
|
+ println!("New Refresh Token: {}", t.secret());
|
|
|
+ (*inner_local.lock().unwrap()).refresh_token = Some(t.clone());
|
|
|
+ }
|
|
|
+ println!("Central post succeeded");
|
|
|
+ } else {
|
|
|
+ println!("Central post failed: {}", r.status().to_string());
|
|
|
+ println!("hit url: {}", r.url().as_str());
|
|
|
+ println!("Status: {}", r.status());
|
|
|
+ (*inner_local.lock().unwrap()).exp_time = 0;
|
|
|
+ (*inner_local.lock().unwrap()).running = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ Err(e) => {
|
|
|
+ println!("Central post failed: {}", e.to_string());
|
|
|
+ println!("hit url: {}", e.url().unwrap().as_str());
|
|
|
+ println!("Status: {}", e.status().unwrap());
|
|
|
+ // (*inner_local.lock().unwrap()).exp_time = 0;
|
|
|
+ (*inner_local.lock().unwrap()).running = false;
|
|
|
}
|
|
|
-
|
|
|
- (*inner_local.lock().unwrap()).access_token = Some(access_token.clone());
|
|
|
- if let Some(t) = res.refresh_token() {
|
|
|
- println!("New Refresh Token: {}", t.secret());
|
|
|
- (*inner_local.lock().unwrap()).refresh_token = Some(t.clone());
|
|
|
- }
|
|
|
- println!("Central post succeeded");
|
|
|
- } else {
|
|
|
- println!("Central post failed: {}", r.status().to_string());
|
|
|
- println!("hit url: {}", r.url().as_str());
|
|
|
- println!("Status: {}", r.status());
|
|
|
- (*inner_local.lock().unwrap()).exp_time = 0;
|
|
|
- (*inner_local.lock().unwrap()).running = false;
|
|
|
}
|
|
|
},
|
|
|
- Err(e) => {
|
|
|
- println!("Central post failed: {}", e.to_string());
|
|
|
- println!("hit url: {}", e.url().unwrap().as_str());
|
|
|
- println!("Status: {}", e.status().unwrap());
|
|
|
- // (*inner_local.lock().unwrap()).exp_time = 0;
|
|
|
- (*inner_local.lock().unwrap()).running = false;
|
|
|
+ None => {
|
|
|
+ println!("No id token???");
|
|
|
}
|
|
|
}
|
|
|
+ },
|
|
|
+ Err(e) => {
|
|
|
+ println!("Error posting refresh token: {}", e)
|
|
|
}
|
|
|
}
|
|
|
}
|