Examples for using Google Admin SDK API (python) - python

We use Google Apps at my organization. I am trying to just use my API key (no oauth2) to get access to users info through the Directory API in the Admin SDK. I cannot find useful examples and the Google docs are buggy. I have had a great deal of difficulty with Google's API documentation. Or perhaps I have to use oauth2?
Even if I knew some of the details about this specific API, I can't find sample code for using these APIs in Python. Does anyone have sample code or links to real-world samples? I am new to Python and we're working on the App Engine.

You must use OAuth2 authentication, API key alone is not enough as you must authenticate as a Google Apps super admin or delegated admin (with appropriate rights) in order to perform Admin SDK Directory operations.
My project, Dito GAM was recently updated with full support for Admin SDK calls. It makes use of most (all?) Directory API calls. See:
https://code.google.com/p/google-apps-manager/source/browse/trunk/gam.py
Also, if you notice bugs or ambiguities in the Google documentation, be sure to report them. It won't get any better if someone doesn't tell them about it! Use the "Report a bug" link at the bottom of all developers.google.com pages. It's very simple to use and pinpoint the exact issue.

Related

Google plus authentication on Google App Engine Python Example

I read tons of documentations, but I cannot find e real full-working example of a Python Google App Engine that simply gives a Login/Logout button to the GOOGLE PLUS authentication system.
Probably this is due to my limited understanding.
My need is to use the info on the backend side in order to give customized contents.
Maybe that's because apparently Google+ Sign-In is being phased out, replaced by Google Sign-In: https://developers.google.com/identity/sign-in/web/quick-migration-guide.
If you're just starting it's probably better to go directly to the newer method (or maybe check if other alternatives might be available/better fitted for your app: https://developers.google.com/identity/) then re-focus your searches accordingly.
Also very important (for most if not all newer authentication methods) - pay attention to the implementation guides:
no code example will be working out of the box as various application-specific service configurations are usually needed as well
no code example will be complete since it needs to incorporate application-specific keys or other pieces of info that can only be obtained from the above service configurations
At the end I solved the problem using simpleauth.
https://simpleauth.appspot.com/
Surely the easyest and efficient way to add oauth2 authentication in your website.

OAUTH2 Python Facebook Login

I am new to web programming- I've recently been familiarizing myself with the webapp2 framework. I'm trying to start building a website, and would like users to login to the site with Facebook and I'll need access to their friends list. I've been trying to find a way to do this- I found out about OAUTH2, and I think this may be a way to do this. All the tutorials for python and OAUTH2 that I've found have been using the google API, I'm not sure if it's any different, but I haven't been able to get it to work.
Does anyone have sample code they can post that uses OAUTH2 (or anything else) to get users to sign in through Facebook? Or any good resources that can help me with this?
Your app needs to authorize users with Facebook, since there's where the resources you need are (e.g. friend lists).
This is a classic use of OAuth2 and you don't have a way around it, because FB implements this protocol.
My suggestion is that you look at the Google sample and then adjust it for FB API. The important changes are:
The endpoint URLs (e.g. authorize, token and user profile
The scopes that define the extent of permissions you are requesting (e.g. list of friends)
The user profile (e.g. the information returned by FB on a user: name, e-mail, etc)
This is a very simple sample that does this in Python. It was meant to run in Google App Engine. The only caveat is that it uses our own library to encapsulate the flow. But you can use it to study how the basic protocol works. Run the live demo and turn on dev tools on your browser to see the network activity.
You will notice that OAuth2 is a rather simple protocol, using simple HTTP requests.

Google Apps Python provisioning API & OAuth mess

I'm trying to provision (among other things) groups for our Google Apps domain, using python. I'm also attempting to using OAuth to authorise my application. The API documentation for Python seems to be missing or broken links. But from searching through the code, it seems I can't use the new (GDClient) APIs as (among other things) I can't get a list of group owners (which I can do in the older GDataService API). And the API for group settings seems to be either the old GDataService, or the even newer apiclient API, but I can't perform basic group provisioning using that API. So it seems I'm stuck using the GDataService API. However, I can't get my head around how to use OAuth for GDataService objects - I can create an oauth token using oauth2client, but can't authorise a GDataService object using this token.
Any pointers as to where to go from here? I'm struggling to believe how messy this all is
The provisioning API is still on the older GDataService API. It is being replaced by the new API called directory api (check out here https://developers.google.com/admin-sdk/)
If you just want to at least get start and familiar with the OAuth flow. You should check out this documentation for the Python API client library: https://developers.google.com/api-client-library/python/start/installation
Try the quick start. All you have to do is select the API you want to use, and select the platform (I usually just picked command line). Click 'Configure Project'. Make sure you are already logged in you Google Apps account that you used to create your project in API console. Select your API project and then finally download the whole package.
Remember to replace your client secret file and just run the sample python code. It will do all the OAuth flow for you.

What python library I should use for facebook OAuth and OpenGraph

I have designed a Facebook application and need to add OAuth, Open Graph for complete functionality. Considering that I know nothing about Open Graph and little JS, I'd like to use a small wrap-up (python lib) which will provide the those features..
I searched over Google, stackoverflow and found few projects which provide some cool features but I am unable to choose..
python libs:
django-social-auth
fandjango
facepy
pyFacebook - I think this doesn't offer OAuth.
I also use Google Data API in my project. So, the better option would be django-social-auth but I am not sure if I can do Open Graph with it..
Can anyone tell me what is the best, maintained, good lib?
(Please do mention if its not in the above list)
django-social-auth is really great if you want to build a website that allows users to log in with Facebook, but if you're building an application on Facebook.com you probably want to use something like fandjango. Either way, you will need a different kind of library (like, say, facepy) to interact with Facebook's API once you've retrieved an access token from the user.
Full disclosure: I am the author of fandjango and facepy.
I would highly suggest django-social-auth. Any library than can parse JSON will support Open Graph as FQL and Graph API data can all be retrieved from Facebook's API (REST).
Good luck!

Where can I find a (current) example of code to bulk upload data to Google AppEngine? (For localhost, too.)

I've tried to do it like they describe in the AppEngine docs but I can't get it to accept my upload. (I haven't tried to download.) I want to get it working in the development environment before I tried on the live site.
It's kind of confusing, because I don't know if I should be trying appcfg.py or bulkloader.py. (I mostly tried appcfg.py.) I think it's an authentication problem, as it keeps asking me for the email/password. (Even after I removed 'login: admin' from app.yaml.)
I did --dry_run and it seemed to work, so I think my stuff is well formed.
Before asking for specific debugging help, I thought I would ask if anyone knows of working sample code that I can download. I run OS X 10.6, if anyone cares. I'm not new to Python, and have a lot of web.py experience, so it's probably not unfamiliarity with the language that's tripping me up.
The docs have a section on uploading and downloading data, with examples. You should be using appcfg.py unless you need one of the features of bulkloader.py that are not yet integrated, such as --dump/--restore functionality.
It sounds like the authentication problems you're having are related to Google Apps: If you have an App Engine app that allows any Google account to authenticate, and you have a Google Apps account as administrator, you won't be able to authenticate against your app as an administrator with it, even if you have created a Google account for that email address. You need to create a gmail account, and add that account as an administrator, so you can use that address when you need to authenticate against your app.

Categories

Resources