URL-encode params in mbc auth to prevent weird errors
This commit is contained in:
parent
79fe991daf
commit
6e075c88fa
1 changed files with 5 additions and 1 deletions
|
@ -13,8 +13,10 @@
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
from urllib.parse import quote
|
||||||
from urllib.request import urlopen, Request
|
from urllib.request import urlopen, Request
|
||||||
from urllib.error import HTTPError
|
from urllib.error import HTTPError
|
||||||
|
import functools
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from colorama import Fore
|
from colorama import Fore
|
||||||
|
@ -25,6 +27,8 @@ from ..cliq import cliq
|
||||||
|
|
||||||
history_count: int = 10
|
history_count: int = 10
|
||||||
|
|
||||||
|
enc = functools.partial(quote, safe="")
|
||||||
|
|
||||||
|
|
||||||
@cliq.command(help="Log into a Matrix account via the Maubot server")
|
@cliq.command(help="Log into a Matrix account via the Maubot server")
|
||||||
@cliq.option("-h", "--homeserver", help="The homeserver to log into", required=True)
|
@cliq.option("-h", "--homeserver", help="The homeserver to log into", required=True)
|
||||||
|
@ -40,7 +44,7 @@ def auth(homeserver: str, username: str, password: str, server: str, register: b
|
||||||
if not token:
|
if not token:
|
||||||
return
|
return
|
||||||
endpoint = "register" if register else "login"
|
endpoint = "register" if register else "login"
|
||||||
req = Request(f"{server}/_matrix/maubot/v1/client/auth/{homeserver}/{endpoint}",
|
req = Request(f"{server}/_matrix/maubot/v1/client/auth/{enc(homeserver)}/{enc(endpoint)}",
|
||||||
headers={
|
headers={
|
||||||
"Authorization": f"Bearer {token}",
|
"Authorization": f"Bearer {token}",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
|
Loading…
Reference in a new issue