I make the following request:
to retrieve an access token. This url leads to a login page on vk.com (if not logged in already), then prompts a user to authorize application and then redirects to https://oauth.vk.com/blank.html#access_token={token}&expires_in=0&user_id={id}. So to actually retrieve an access token one needs to manually copy it from the address bar. This procedure is specified in the official API. Is there a way to go around this? How do I get a token using only python code?
Below is the procedure that generates the url:
import requests
def authorize_app(client_id, redirect_uri = None):
'''
The function generates an url, which redirects to login page (optional, if not logged in) and app authorization.
'''
if redirect_uri == None:
redirect_uri = 'https://oauth.vk.com/blank.html' # default callback url
oauth = requests.get('https://oauth.vk.com/authorize', params = {'client_id' : str(client_id),
'redirect_uri' : redirect_uri,
'display' : 'page',
'scope' : ['friends,offline'], # offline option makes the token permanent
'response_type' : 'token',
'v' : 5.63})
return oauth.url
localhost:5000) and redirect the user there, then stop the server once it receives the token. - Aran-Fey