Tip:
Highlight text to annotate it
X
MIHAI LONESCU: Hello.
Welcome to Wallet Developers Live.
We recently launched Google Wallet Objects
and now we're creating a series of short tutorials
to educate developers about the Wallet Objects API.
The topic of today's session is account creation.
And in particular, we're going to talk
about creating two accounts-- your OAuth account
and your Wallet Objects issuer account.
Wallet Objects works with an OAuth to service account model.
That means to grant access to data in Wallet Objects,
you need to tell Wallet Objects your OAuth
to service account and then authorize
using the OAuth credentials.
And we'll go through the steps of generating
those accounts and the associated items
in them one by one.
First, let's create the OAuth service account.
So to do that we'll go to the new Google Cloud API console,
which is at cloud.google.com/console.
And once we navigate there, you'll
see a page which invites you to create a new project.
So to do that, click on Create Project.
And then let's select the project name.
So in this case, let's say my new account.
And you can use the project ID as is
or select another unique identifier.
Of course, agree to the terms of service.
And then let's click Create.
I'll take a few seconds while your project is being created.
And there we go.
Once your project is created, we will
need to enable Wallet Objects.
So for that, go to the APIs and Auth link
on the left navigation side.
And then in here, let's search for Wallet Objects.
And then let's enable the Wallet Objects API.
Now the API is enabled.
And all we have to do is register our application.
For that, click on Register Apps on the left side,
and then on the big red Register App button.
You can select any name you want for your application.
And leave the Web Application radio button selected.
Then click Register.
Take a few seconds, and now your new app is registered.
This will take us to a screen where
it shows available credentials below
to access various types of data.
In our case, we will need to access data
on one of Google's servers.
So select the Certificate section.
And in here click on the Generate Certificate button.
This will create a new certificate for you.
And now your certificate is ready.
It's very important too download the private key file somewhere
on your computer and make a note of where
it is because we will need this credential later on
to authenticate when we access Google Servers.
So let's click on Download Private Key.
And you can download it anywhere.
You can name it-- it's a pretty long name in here.
Just choose a shorter name and save it somewhere.
So let's save this one.
And now we're done.
So two things that are important to note here.
One is the email address of your service
account, which is this one here.
And it's a big string at developer.gserviceaccount.com.
So make a note of that address and save it somewhere.
And of course, remember where you generated
and saved your private key file.
You can always generate a new key by clicking on the button.
And you can use that key as well.
So in this case, we keep the original one.
Now we switch to step two of our configuration, which
is setting up your Wallet Objects account.
The Wallet Objects account is a dashboard
that allows you to manage your Wallet Objects, your classes
and objects that you created.
We'll have more sessions in the future highlighting
the functionality here.
For this session, we'll just focus
on configuring and setting up the account.
To access your Wallet Objects account,
open your browser and go to wallet.google.com/merchant/walletobjects.
So let's navigate there.
And you see for our newly created account,
there is not much there.
To set it up, click on Account Management on the left nav bar.
And here you have some basic account information.
So make a note of the issuer ID.
This is your-- if you want to call it-- merchant ID.
And it's very important to make a note of it
and know what it is.
You will use it later on when we make calls
to Google Wallet Objects.
One extra step you have to do to properly set up the account
is to associate it with your OAuth service account.
So let's share this account with the OAuth service account.
So for that, we will need to select and add
here the email address that we created in the OAuth service
account.
So I'm switching back to the OAuth service account,
and I'll copy paste this address.
And then I'll go back here.
And I'm going to share it with my Google Wallet Objects
account.
Now you're all done.
Your Wallet Objects account is ready to be
used to issue REST calls to Google Server.
So to recap, make a note of your issuer ID.
Make a note of where you saved your key file with the OAuth
credentials.
And also make a note of your issuer account email address.
You can always go to the Cloud Console
if you don't remember it to copy paste it from there.
Or if you don't remember where your keys are,
you can always generate new keys.
And the issuer ID can be found in your Google Wallet Objects
account.
And now that we have our accounts configured
and all set up, let's see what we
can do with all that information.
I will show you how easy it is to use your OAuth
credentials to make JSON calls.
In future session, we will explore
how you can make more complex calls using different languages
like Java, Python, PHP, Ruby.
But for now, we'll just do a very simple call in JSON.
The first step would be to generate
a bearer token as required by the OAuth standard.
We have created a set of tools for you
that makes that very easy.
To generate the bearer token, have a look
at our testing section in the documentation.
And in particular, we have created a Java-based utility
that will allow you to obtain a bearer token.
Our utility is called tokenutil.jr.
And it's open sourced in GitHub.
We have a link from our documentation.
And you can very easily download it
by selecting the Row download and save it
somewhere on your machine.
Once we have that utility handy, then we
can go ahead and request a bearer token.
Going back to our documentation, use the command
I'm highlighting here to obtain the bearer token.
Remember earlier we saved the service account email address.
And I told you to remember where you
saved your private key file.
So with that information, I'm going to use this command here.
Copy paste it and issue a command
to retrieve the bearer token.
So with some information I already saved,
this is my test service account email.
And I saved my credentials in a file called key.p12.
So let's issue that command.
It takes a moment.
And we retrieve back a bearer token.
So now you can copy paste this guy here, and save it
somewhere in a notepad.
And we will use that to issue a JSON command to the Wallet
Objects service.
Remember, this bearer token, it's valid for an hour.
So if later on you want to play again with issuing JSON calls,
remember to generate a new one.
How do we generate calls to Google Wallet Objects?
So we have some examples where we can very easily test
the REST API on our testing page.
So if you page down a little bit to the Test REST API section,
you will see a few examples how you
can query for existing objects or classes,
or how you can get a list of classes, a list of objects,
how we can insert the class.
In future sessions, we'll go in more detail over all of these.
For now, let's just show you how you can easily
retrieve all these tough classes for an account that
has already a few classes in it.
So the command is the one highlighted here.
And very nicely you can use call to issue the command.
So what do you need to change in this template?
Of course, you have to specify a class type.
And in this example, we'll use a loyalty class.
You will need to change the issuer ID with the issuer ID
we generated earlier.
So I'll switch again to your Wallet Objects dashboard.
And remember, the issuer ID is here under Account Management.
And finally, we will use the bearer token
we just generated using the utility tool we provided.
So if in this command we override all this information
and copy paste it somewhere in Notepad.
And I have an example here.
I'll just copy this, and then go to a terminal.
And then we are now ready to issue a command to Google
Wallet Objects to retrieve a list of existing classes.
And here we are.
We received the JSON with all the existing classes
in this Google Objects account.
So in future session, of course, we'll
go in more detail what everything means.
And you'll get a better understanding of the response.
But for today, we accomplished quite a lot.
We set up our OAuth account and our Google Wallet Objects
account.
And with that information, we obtained a bearer token,
and issued a JSON call, and received
a list of existing loyalty classes from our account.
And that concludes the first of our Wallet Objects Tutorials.
In a future session, we'll talk about templates, objects,
and classes.
Until then, goodbye.