Jump to content

OpenID login API problem - Python

OpenID login API Python

  • Please log in to reply
1 reply to this topic

23gale #1 Posted 27 June 2020 - 04:34 PM


  • Player
  • 32277 battles
  • 18
  • Member since:

Hi, i'm trying to develop a python program and i've a problem with the OpenID login API.
I use request.get() to recive JSON  for the other API, but in this case i have to access to the web page, logging in and than recive the JSON data, but i don't know how to identify my app as the redirect_uri:
can you help me? thanks
(the program should stay on my desktop and it'll not be loaded on a server as a webservice, so i don't have any Ip address)

That's an example how i get API:

base_url= "https://api.worldoft...an_id&search={}"
query_url= base_url.format(clan_tag)

req = requests.get(query_url)
req = str(req.text)
js = json.loads(req)

But i can't use this method 'cause request.get() give back the website's HTML 

(sorry for my bad english

Edited by 23gale, 27 June 2020 - 04:34 PM.

lgfrbcsgo #2 Posted 07 July 2020 - 11:31 AM

    Second Lieutenant

  • Player
  • 39970 battles
  • 1,102
  • Member since:

You can omit the redirect URI parameter.


The simplest way to obtain the token would be to open that URL (e.g. https://api.worldoftanks.eu/wot/auth/login/?application_id=<your application id goes here>) in your browser, login, and then (after the redirect) manually copy the token from the URL into your application (e.g. https://api.worldoftanks.eu/2.0/blank/?&status=ok&access_token=<extract access token from here>&nickname=lgfrbcsgo&account_id=502907751&expires_at=1595327083).


Alternatively, you need to either

- use an embedded browser which allows you to read the URL after the redirect,

- start a local HTTP server which can be used as a redirect target, or

- register a custom protocol to launch your app from a webpage https://weblogs.asp.net/morteza/How-to-run-a-desktop-application-from-a-web-page


You probably shouldn't start a local server though, as this has a few security implications.


OpenID Connect wasn't designed with native apps in mind. The easiest solution would be to implement your app as a web app. I've made a very simple sample web app some time ago which fetches data about clan reserves: https://lgfrbcsgo.github.io/wot-sample-client-app/

Edited by lgfrbcsgo, 07 July 2020 - 01:11 PM.

Also tagged with OpenID, login, API, Python

1 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users