Skip to content

Commit 3b98f47

Browse files
committed
The redirected tab on requesting a code is now automatically closed.
1 parent 9aea269 commit 3b98f47

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

spotify_api/src/api_model/credentials.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,15 @@ pub mod Code {
6767

6868
auth_code = value.to_string();
6969
}
70-
71-
let message = "OK";
70+
71+
// This html closes the tab itself automatically.
72+
let message: String = vec![
73+
"<!DOCTYPE html>",
74+
"<html>",
75+
"<body onload=\"open(location, '_self').close();\">",
76+
"</body>",
77+
"</html>"
78+
].concat();
7279
let response = format!{"HTTP/1.1 OK\rcontent_length: {}\r\n\r\n{}", message.len(), message};
7380
stream.write_all(response.as_bytes()).unwrap();
7481
break;

0 commit comments

Comments
 (0)