[SWOOSHING]
GUS CLASS: Hello, Google+ Developers.
I'm Gus Class, and I'm on developer relations for the
Google+ team.
And today, we're going to be talking about the Python
quick-start.
And so naturally, we brought in one of our Python experts
from the Drive team, Ali Afshar.
ALI AFSHAR: Hi, everyone.
Thanks for coming.
GUS CLASS: So a little trivia about Ali is he
wrote his own IDE.
ALI AFSHAR: So I wrote two IDEs actually.
They're great if you want to check them out.
One of them's called PIDA, one of them's called Abominade.
They're both written in Python, and you can like them
if you like Vim.
GUS CLASS: There you go.
Well, it's great to have you here, Ali.
And so let's get to the quick-start video that we've
been working on this week.
And so we're going to just take a quick look at it, and
it's a screen cast that we did to show you how quick it is.
The instructions for the Python quick-start are
available on developers.googl e.com/+/quickstart/python.
The first step in the instructions is to enable the
Google+ API.
This is what you do before starting any project.
Navigate to code.google.com/apis/console.
When you're here, create a new project.
And then give your project a title for you.
After you create the project, you'll be redirected to the
services pane.
Inside of the services pane, you'll need to turn on the
Google+ API.
After turning on the Google+ API, create a client ID and
client secret by navigating to API Access.
The information that you enter into this first window will be
customer facing, so carefully pick it.
Next, set the authorized JavaScript origin to local
host port 4567, as configured in the sample.
Also, set the protocol to HTTP.
After you've created your client ID and client secret,
you're ready to clone the project.
Run the git clone command to clone the Python quick-start
from GitHub.
Next, set up Python as you would do for any
other Python project.
And so I'll just use Virtual Environment.
Next, go into the project folder, and then install all
of the Python requirements by running pip install dash r
requirements.txt.
After the requirements are installed, you're ready to set
the client ID and client secret in clientsecrets.JSON.
Copy and paste the client ID from the API console project
you created, and copy the client secret from the API
console project.
After you've put the client ID and client secret in, you're
ready to run the sample.
Just run Python signin.py to start the sample.
You'll be prompted for turning on the web server, so just
make sure that you approve it.
And then navigate in a web browser to local host port
4567, authorize the application, and
you will see it run.
You've now run the Python quick-start.
So that's it.
That's how long it takes to run through the Python
quick-start.
And we timed me, and it took me just about
two and a half minutes.
So it's really easy to do, and you can see it going
right out the gate.
But you're probably asking, what are the next things you
can do with the Python quick-start?
And so some of the things that we thought about doing were
deploying it to a cloud hosted service, such as
Heroku or App Engine.
Ali, are there any changes that would have to be made
inside of the quick-start sample, in order to be capable
of deploying it to these solutions?
ALI AFSHAR: So this is what I really like about your
quick-start sample is that you use a web
framework called Flask.
It's very close to my heart, written by a number of people
I know and I've contributed to.
It's a very light framework.
It's very easy to use.
And of course, with Python, as with any Python web framework,
it's built on WSGI, the web server gateway interface that
is this common infrastructure for web applications to talk
to web servers.
So really, no, you can just dump that thing anywhere you
like, and it will run.
So it will run on App Engine.
App Engine supports WSGI.
It will run on Heroku.
It will run on just about any way you can host files.
If you just have an Apache server, well,
that will work too.
So that's what I really like--
Flask.
Check it out.
If you haven't checked it out, and you use Python at all-- if
you use Python at all, of course, you would have checked
it out already.
If you haven't, and you're getting into
that, check it out.
It's like almost the anti-Django.
It's like a light, useful, flexible framework, whereas
Django is a less light framework.
GUS CLASS: Yeah, I mean in our sample, we were really trying
to get it down as narrow as possible and make it as easy
for developers to use.
And it's good to hear that you agree with some of the choices
that we made.
And you're on the Drive API, so you probably have done
these integrations before between the Sign-in
solution and Drive.
So do you have any suggestions for developers?
And what would they do to get Drive integrated?
And then what would be something cool that someone
could do after integrating with Drive?
ALI AFSHAR: So we have Drive quick-starts,
as well, very similar.
The Python one is very similar.
We actually don't need a web server to use the Drive API.
So we just have a command line application, so it's
easier in that way.
Integrating + Sign-in is very easy.
You go through, and you add the Drive Scope--
that's an OAuth 2 scope.
And you add that scope, and then immediately, you can
start making requests to the Drive API.
It's beautiful, because the scopes you request when you do
authorize the user, those are all union together.
So I can then get a client, an authorized HTTP client that
can make requests against the Drive API and make requests
against the + API, and make requests against any of our
APIs, really.
You just have to ask for access.
So that's really, really nice.
What our quick-starts do is we just upload a file.
So in your use case, I think the most simple functionality,
and you've done that really well, is just to find out who
the user is or find out their friends or
something like that.
Our quick-start, we just upload a file, so you select a
file and you upload it, pretty simple, but get on.
So one extra thing I just wanted to talk about was your
use of Virtual Environment.
Now I'm really, really happy to see that.
And since you brought me on to talk about Python, I guess I
should just bash my stick a bit, which is when you run a
Python sample, or when you install a Python sample,
always use Virtual Environment.
Why?
Because you don't want to actually
use your system Python.
The system Python is there for the system to run.
And we're well past the days when a Ubuntu system or a Mac
system wouldn't actually need Python installed.
But now these systems use Python, and they use them, in
depth, for lots of core functionality.
So when you're installing something using pseudo-pip
install, you have the ability to really overwrite something
that the system is using and something that is critical for
the function of your computer.
You don't want to do that.
So my takeaway for this is if you have to run pseudo-pip
anything, you're probably doing something wrong.
So check out Virtual Env.
Obviously, check out pip.
Pip and Virtual Env are written by the same guy,
originally.
So they integrate very, very well.
One will install the other.
So that's my tip to takeaway.
Always use a virtual environment.
And thanks for doing that, because that's
made me very happy.
GUS CLASS: Yeah, OK, good.
Well, I'm glad to have made you happy, Ali.
Do you have any questions for me about Google+?
ALI AFSHAR: So tell me--
I've seen it a bit.
I've seen your API a bit.
So just in a few lines, tell me why + Sign-in?
Why is that good for me?
Why is that good for my applications?
GUS CLASS: Yeah, well, one of the key things that we're
doing in the sample is getting that client authorized as well
as the server, so you can then, using the Google+
Sign-in API, by connecting your account with Google, what
you're doing is you're authorizing the client on
JavaScript, and you're authorizing the server.
So then you can do all of those operations that you want
to do client side, as well as server side.
And because of the way that the client libraries work, you
can then, as you said, request all the scopes that you want
and then get access to the entire suite of functionality
that is available through the Google platforms.
So this is a really powerful tool for developers to get
their users integrating Google functionality with their
actual third party sites.
ALI AFSHAR: That's cool.
So I get authorization and I get authentication, as well?
GUS CLASS: Yeah.
ALI AFSHAR: OK, awesome, great.
So I'm a real fan.
It's something I've been using in my pet projects.
It's just so much easier to just put a bit of HTML on a
page and then sign-in auth is just solved for me.
So I love that, so thanks very much.
Keep that up.
GUS CLASS: Yeah, for sure.
And yeah, so that's pretty much it for the Python
quick-start.
Inside of that quick-start, what's happening is that the
client's authorizing, it's passing an authorization code
to the server.
And then the server's authorizing, so then both are
authorized.
And then some of the API calls are performed on the client,
most notably the profile retrieval.
And then some of the APIs are performed on the server, which
is that Circles, the people list.
And so the sample just highlights those two steps for
using the Google+ API.
ALI AFSHAR: So yeah, it was three minutes to go through.
But I think you can easily spend a few hours picking the
bits out that are useful to you for your application.
GUS CLASS: Yeah, it's really worth mentioning that you can
go to the Google APIs Explorer to see the scope of what you
can do with the APIs and experiment with those
particular API calls.
So this is a great pro tip.
If you go to code.google.com/apis/explorer,
you can explore the APIs and experiment with what's there.
So that's a really great place to explore what you can do
after you've got that sample going.
So that's pretty much what we have for today.
There's a couple of announcements before we close.
The first is that now the People Search API will allow
you to search for a Google+ user by email.
And the next is that there has been a recent update to the
Android Google Play services libraries that improves the
experience for sharing and signing in on Android.
So for those really astute Google+ Developers out there,
make sure that you check out the new platform
functionality.
And feel free to ask us questions in the Google+
Developers community.
And if you're looking for the Google+ Developers resources,
the top ones will always be listed at
developers.google.com/plus.
So thanks for watching, and come back next week for
another Google+ Developers Live.
ALI AFSHAR: Thanks.
[SWOOSHING]