blob: c3a893ddb7de23b7c4130a50392c8b06fb77f641 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# Copyright (C) 2024-2025 Maria Lisina
# Copyright (C) 2024-2025 Danil Lisin
# SPDX-License-Identifier: Apache-2.0
ib_auth_file="${cache}/${update_id}_user.json"
dump+=(${ib_auth_file##*/})
if ! curl --data-urlencode "username=${ib_login}" \
--data-urlencode "api_key=${ib_key}" \
--get \
--max-time ${external_timeout} \
--output "${ib_auth_file}" \
--proxy "${external_proxy}" \
--silent \
--user-agent "${useragent}" \
"${ib_auth}/user.json"
then
output_text="Failed to access ${ib_name} API"
log_text="ib_auth (${update_id}): ${output_text}"
. "${units}/log.zsh"
. "${units}/dump.zsh"
return 0
fi
if ! jq -e '.' "${ib_auth_file}" > /dev/null
then
output_text="Invalid username or API key"
log_text="ib_auth (${update_id}): ${output_text}"
. "${units}/log.zsh"
. "${units}/dump.zsh"
return 0
fi
printf '%s="%s"\n%s="%s"\n' \
"ib_dfield5" "username=${ib_login}" \
"ib_dfield6" "api_key=${ib_key}" > "${legacy_file}"
|