I figured it out... OAuth2Login_Serv( should have been OAuth2Login(

On Tuesday, August 11, 2015 at 7:36:29 AM UTC-7, kipodiha wrote:
>
> I spent a lot of time surfing between answer\examples and google docs....
>
> there is only one way that worked for me. In this example you get once web 
> page to authriase (but only once, not each time of running - it is ok for 
> me)
> I took this solution from here 
> http://stackoverflow.com/questions/30474269/using-google-picasa-api-with-python,
>  
> see answer of Carceri <http://stackoverflow.com/users/4961087/carceri>
>
> from his readme:
>
> You need to use OAuth2 for authentication. Here is how to set it up:
>
>    1. First create a project through the Google Developer Console: at 
>    https://console.developers.google.com/
>    2. Under that project, create a new Client ID of type "*Installed 
>    Application*" under APIs & auth -> Credentials
>    3. Once the Client ID has been created you should click "Download 
>    JSON" and save the file as ...../client_secrets.json (you can change the 
>    location in main.py)
>
> The first time you run the application you will be asked to authorize your 
> application through your web browser. Once you do this you will get a code 
> which you have to copy and paste into the application.
>
>
> from datetime import datetime, timedelta
> from oauth2client.client import flow_from_clientsecrets
> from oauth2client.file import Storage
>
>
> def OAuth2Login(client_secrets, credential_store, email):
>     scope='https://picasaweb.google.com/data/'
>     user_agent='picasawebuploader'
>
>     storage = Storage(credential_store)
>     credentials = storage.get()
>     if credentials is None or credentials.invalid:
>         flow = flow_from_clientsecrets(client_secrets, scope=scope, 
> redirect_uri='urn:ietf:wg:oauth:2.0:oob')
>         uri = flow.step1_get_authorize_url()
>         webbrowser.open(uri)
>         code = raw_input('Enter the authentication code: ').strip()
>         credentials = flow.step2_exchange(code)
>
>     if (credentials.token_expiry - datetime.utcnow()) < timedelta(minutes=5):
>         http = httplib2.Http()
>         http = credentials.authorize(http)
>         credentials.refresh(http)
>
>     storage.put(credentials)
>
>     gd_client = gdata.photos.service.PhotosService(source=user_agent,
>                                                    email=email,
>                                                    
> additional_headers={'Authorization' : 'Bearer %s' % credentials.access_token})
>
>     return gd_client
>
>
> if __name__ == '__main__':
>     email = "[email protected] <javascript:>"
>
>     # options for oauth2 login
>     configdir = os.path.expanduser('C:/Python27/')
>     #client_secrets = os.path.join(configdir, 'julia-5d03e3b361d0.json')
>     client_secrets = os.path.join(configdir, 'client_secrets.json')
>     credential_store = os.path.join(configdir, 'credentials.dat')
>
>     gd_client = OAuth2Login_Serv(client_secrets, credential_store, email)
>     
>     albums = gd_client.GetUserFeed()
>
>
> If somebody has working solution for Service APP you are welcome to share :)
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Picasa Web Albums API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-picasa-data-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to