This project is a consumption example of Riot Games Developer API (RGAPI).
To setup this project locally a few steps are needed, they are:
- Configure environment variables
- [Add rule for localhost domain (only for oauth2 authentication)] (#add-rule-for-localhost-domain-only-for-oauth2-authentication)
- Install python dependencies
You should install some dependencies to use the app:
- pip install Flask
- pip install python-dotenv
- pip install dataclasses
- pip install numpy
- pip install Flask-Session
You can get the API Key after sign in at Riot Games Developer Portal. This token will be used as environment variable APP_KEY
.
For oauth2 authentication are needed two credentials, they are CLIENT_ID
and CLIENT_SECRET
and will be used respectively for environment variables RSO_CLIENT_ID
and RSO_CLIENT_SECRET
. Provided by (https://developer.riotgames.com/)
Copy file .env.example
to a new file named .env
.
Set the environment variables with the credentials created in the last steps. For example:
APP_PORT=5000
APP_CALLBACK_PATH = <YOUR-CALLBACK-PATH>
RSO_CLIENT_ID=<YOUR-CLIENT-ID>
RSO_CLIENT_SECRET=<YOUR-CLIENT-SECRET>
APP_KEY=<YOUR-API-KEY>
To use oauth2 authentication redirect flows is needed to match your app hostname with the redirect_uri
provided when getting credentials for oauth2.
Open hosts file C:\Windows\System32\Drivers\etc\hosts
Add your hostname to localhost ip
127.0.0.1 local.testingapp.com
Open hosts file: sudo nano /etc/hosts
Add your hostname to localhost ip
127.0.0.1 local.testingapp.com
After [booting server] make a request GET localhost:5000/summoners/overview?region={summonerRegion}&name={summonerName}
Available regions are:
- BR1
- EUN1
- EUW1
- JP1
- KR
- LA1
- LA2
- NA1
- OC1
- RU
- TR1
curl -X GET "localhost:5000/summoners/overview?region={region}&name={summonerName}"
Navigate to localhost:5000/summoners/overview?region={region}&name={summonerName}
{
"id": "summonerID",
"name": "SummonerName",
"profileIconId": 1,
"summonerLevel": 10,
"revisionDate": "2022-01-17T18:14:50-03:00",
"leagueEntries": [
{
"leagueId": "leagueID",
"queueType": "RANKED_SOLO_5x5",
"tier": "CHALLENGER",
"rank": "I",
"leaguePoints": 1071,
"wins": 194,
"losses": 164,
"hotStreak": true,
"veteran": true,
"freshBlood": false,
"inactive": false
}
]
}
For this example we will authenticate through RSO (Riot SSO) and request account data by using oauth2 access token.
- Open the example app with the host you defined
- Follow the
Auth
link
You will be redirected to Riot SSO Login Page. Authenticate using your account credentials.
After login you will be redirected to local app. Click Main menu
. The app will request /riot/account/v1/accounts/me using an access token of your account.
When following My Account
you receive a response with the same structure of this example:
{
"puuid": "Player Universal Unique ID",
"gameName": "Game Name",
"tagLine": "Tag Line"
}
The json values are only examples. For puuid you will receive an encrypted string.
Go to app home page and click Logout
.