stelar7/R4J

Feature request: Allow credentials to be set per API call

lolbyte-code opened this issue · 3 comments

To set credentials you do something like R4J(APICredentials(apiKey)). This updates global state such that any subsequent API operation uses those credentials. This works fine if you're only using one Riot API key but not well at all if you have multiple in one application (TFT, League, etc.)

I am requesting an enhancement to the API where you can set the credentials per call. For example, instead of Summoner.byAccountId(leagueShard, id), maybe you could do Summoner.byAccountId(leagueShard, id).withCredentials(APICredentials(apiKey)).

Thanks!

Hello @lolbyte-code !

I'm not sure to understand your issue, have you tried to use this solution ? You can this way choose which api (and key) you want to use.

APICredentials creds = new APICredentials(leagueTocken, tournamentLeagueTocken, tftTocken, lorTocken, valorantTocken); //you can set to null the one you are not using
R4J r4j = new R4J(creds);

r4j.getLoLAPI().getSummonerAPI().getSummonerByName(LeagueShard.EUW1, "summonerName"); //Use LoL tocken
r4j.getTFTAPI().getSummonerAPI().getSummonerByName(LeagueShard.EUW1, "summonerName"); //Use TFT tocken

@KaluNight - Ooo nice! I can give that a shot. It seems that I wasn't using the APIs as intended 😉

Ok great that worked perfectly. TYSM @KaluNight!