VK API : automatically generate acess token by using python
Question: I am trying to acess VK Api with scope of stats. manually i am able to
generate acess token ,but that is going to be expire in 24 hours. So i wanted
to generate acess token programatcally. i tried in 2 ways mentioned as below.

first way:

    
    
    import requests
    response=requests.get('https://oauth.vk.com/authorize?client_id=myclientid&scope=stats&redirect_uri= myredirecturi& display=page&v=5.53&response_type=token ')
    print r.url (my expectation is it should give that redirect url with acess token, but that is returning url which i am passing as argument.)
    

second method:

    
    
    import vk
    session=vk.AuthSession(app_id='myappid', user_login='myusername', user_password='mypassword')
    api = vk.API(session)
    

returning Vkauth error 'redirect_uri' mismatch. Can anyone suggest how to
solve this and how to get acess token automatically.


Answer: Look at the way of authorizing I described in
[that](http://stackoverflow.com/questions/31912670/spring-social-vk-vkontakte-
how-to-fetch-user-photo-albums/31915379#31915379) post. It's called 'straight
auth' which is used by official VK applications for iOS/Android/etc, that
token has grant rights and no limit for its lifetime value.

