How to generate RequestToken URL for Google API
Question: I'm writing Python 2.7 desktop application which needs to access Google
Spreadsheets using OAuth 2.0. I'va found a library for Google Spreadsheets for
python [here](https://github.com/burnash/gspread) which uses
[this](https://github.com/google/oauth2client) python OAuth2.0 library. The
flow for desktop applications described
[here](https://developers.google.com/accounts/docs/OAuth2#installed) tells me
that I have to generate RequestToken URL first which user can use to get
Authorization Code to the application.

I already have Client ID and Client Secret generated in Developer's Console.
But I can't figure out what class/method I can use to generate RequestToken
URL in python.

Should I somehow construct it myself or is there an API to do it?


Answer: I've figured it out from documentation
[here](https://developers.google.com/api-client-
library/python/guide/aaa_oauth#step1_get_authorize_url)

    
    
    #!/usr/bin/env python
    
    import oauth2client
    
    from oauth2client.client import OAuth2WebServerFlow
    
    flow = OAuth2WebServerFlow(client_id='your_client_id',
                               client_secret='your_client_secret',
                               scope='https://spreadsheets.google.com/feeds',
                               redirect_uri='urn:ietf:wg:oauth:2.0:oob')
    
    auth_uri = flow.step1_get_authorize_url()
    
    print auth_uri
    

You'd need your own client_id and client_secret here though.

