mirror of
https://github.com/polybar/polybar.git
synced 2026-03-05 15:59:37 +00:00
Update: Using another way to authenticate github module (#2029)
The github module only authenticate by query string, and this method is deprecated: https://developer.github.com/changes/2019-11-05-deprecated-passwords-and-authorizations-api/#authenticating-using-query-parameters There is no reason to remove it before the method stop working, so I've made possible to the user choose which authentication method he will use: * The parameter token remain unchanged. * If the parameter user is passed then the module will use the not deprecated method, passing user and token on the body of the requisition. Otherwise the module will use the deprecated method. Co-authored-by: Lucas <araujo.lucasvale@gmail.com> Fixes #2002
This commit is contained in:
@ -17,6 +17,7 @@ namespace modules {
|
||||
github_module::github_module(const bar_settings& bar, string name_)
|
||||
: timer_module<github_module>(bar, move(name_)), m_http(http_util::make_downloader()) {
|
||||
m_accesstoken = m_conf.get(name(), "token");
|
||||
m_user = m_conf.get(name(), "user", ""s);
|
||||
m_api_url = m_conf.get(name(), "api-url", "https://api.github.com/"s);
|
||||
if (m_api_url.back() != '/') {
|
||||
m_api_url += '/';
|
||||
@ -52,7 +53,12 @@ namespace modules {
|
||||
}
|
||||
|
||||
string github_module::request() {
|
||||
string content{m_http->get(m_api_url + "notifications?access_token=" + m_accesstoken)};
|
||||
string content;
|
||||
if (m_user.empty()) {
|
||||
content = m_http->get(m_api_url + "notifications?access_token=" + m_accesstoken);
|
||||
} else {
|
||||
content = m_http->get(m_api_url + "notifications", m_user, m_accesstoken);
|
||||
}
|
||||
|
||||
long response_code{m_http->response_code()};
|
||||
switch (response_code) {
|
||||
|
||||
Reference in New Issue
Block a user