简体   繁体   中英

How to fix a “Invalid authentication credentials” error when accessing an API

I am trying to access the fortnite tracker api ( https://fortnitetracker.com/site-api ) to download some data and perform some analysis.

I have a key but each time I try to pass it as a header (per the website above), I keep receiving a "Invalid authentication credentials" error. I have tried passing in my username and password, but that has not worked either.

import requests
session = requests.session()
api_key = 'XXXXXXXXXXXXXXX'
make_link = lambda player,platform: 'https://api.fortnitetracker.com/v1/profile/{}/{}'.format(platform,player) #this just makes the link for the proper player
sample_platform, sample_player = 'pc','Ninja'
sample_link = make_link(sample_epic_name,sample_platform)
headers = {'TRN-Api-Key': api_key} #this is the name of the api-key per the link
session.get(sample_link, headers = headers).content #this returns a message that specifies my original error: "Invalid authentication credentials"

I want to just be able to overcome the access issue of this API so that I can use it. Please let me know if I need to make any changes. I found the link listed above to be helpful but not for novice API users such as myself. Thank you!

I experienced the same problem and contacted their support a few days ago. This is what they answered yesterday.

We had a issue in our system that was not activating api keys correctly, so you may have been getting 403 or 401 errors. This has been corrected.

I have tried it out again using curl --header "TRN-Api-Key: <my_key>" https://api.fortnitetracker.com/v1/store and it's now working for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM