I am building an R package for fantasypremierleague
I want the json from here : https://fantasy.premierleague.com/api/my-team/965197
But, to access this I need to login first.
The login url is 'https://users.premierleague.com/accounts/login/'
I could get this to work using request package in Python.
I am trying to use httr package in R. However, since the api url and login url are different, authenticate() does not work.
Below is the python code that works. How can I translate this into R?
import requests
session = requests.session()
url = 'https://users.premierleague.com/accounts/login/'
payload = {
'password': 'pass',
'login': 'email',
'redirect_uri': 'https://fantasy.premierleague.com/a/login',
'app': 'plfpl-web'
}
session.post(url, data=payload)
response = session.get('https://fantasy.premierleague.com/api/my-team/965197')
print (response.json())