Created method to produce an authenticated session
This commit is contained in:
parent
eaeb1c1b7f
commit
70cfef54ad
1 changed files with 19 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import requests
|
import requests
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
from pydantic import HttpUrl
|
from pydantic import HttpUrl
|
||||||
|
import requests
|
||||||
|
|
||||||
from classes.boardgame import BoardGame, BoardGameExpansion
|
from classes.boardgame import BoardGame, BoardGameExpansion
|
||||||
|
|
||||||
|
|
@ -57,3 +58,20 @@ def get_boardgame(boardgame_id: int) -> BoardGame:
|
||||||
requested_boardgame = convert_xml_to_boardgame(boardgame_xml_object.find('item'))
|
requested_boardgame = convert_xml_to_boardgame(boardgame_xml_object.find('item'))
|
||||||
|
|
||||||
return requested_boardgame
|
return requested_boardgame
|
||||||
|
|
||||||
|
def get_authenticated_bgg_session(username: str, password: str) -> requests.Session:
|
||||||
|
login_url = "https://boardgamegeek.com/login/api/v1"
|
||||||
|
|
||||||
|
post_data = {
|
||||||
|
"credentials":{
|
||||||
|
"username": username,
|
||||||
|
"password": password
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
authenticated_session = requests.Session()
|
||||||
|
login_response = authenticated_session.post(login_url, json=post_data)
|
||||||
|
|
||||||
|
print(login_response.status_code)
|
||||||
|
|
||||||
|
return authenticated_session
|
||||||
Loading…
Reference in a new issue