Getting started with the Google Mirror API: Java

Getting started with the Google Mirror API: Java


Hi, I’m Jenny on the Glass
Developer Relations team. And today, I’m going to show you
how to get up and running building Glassware with Java. So the fastest way to build
Glassware is using the quick start projects we have. They’re available in several
different languages. But today, we’re talking
about Java. So let’s click here and go
to the Java quick start. Sometimes you’ll want to
look before you leap. So let’s take a look at the demo
to see what we have here. Here’s the Java quick start. It is the easiest way to start
building Glassware. It provides a foundation for you
to build your projects on top of, so you can get started
fast without worrying about the boilerplate code. And it also demonstrates a few
common functions that we think your Glassware is going
to include. You can send timeline items to
one user, with attachments. You can set items to
all your users. You can work with
notifications, that kind of stuff. So let’s show you how
to get the code. You can click on this big button
to go to GitHub and download the source code. Click on the Download
ZIP button. Watch it download. Then we’re going to
go over into our terminal to set it up. First thing we’re going to
want to do is unzip it. You can see a whole bunch
of files got extracted. But we only need to modify
one to get started. We just need to set some
configuration parameters. So we’re going to go
in to the directory and modify this file– oauth.properties. There are two fields that
we’re setting here. We’re setting our client ID
and our client secret. You can get both of these
values from the Google API’s console. You can get to the Google API’s
console by going to code.google.com/apis/console. So I created a new project. But if you’ve never created
one before, one will automatically be created
for you. The first thing we’re going to
do is turn on the Mirror API. So we’re going to scroll down
and enable the Google Mirror API here by clicking
on this toggle. You might be asked to
accept some terms. Just click Accept. Next, we’re going to set
up the API access. So we’re going to go to the API
Access panel and click on the inviting giant
blue button. Here, we’re going to
name our Glassware. And then we’re going to tell it
a little bit about how our project is set up. Mirror API Glassware are web
applications, so we’ll leave that set to the default. But we’re going to start
by running it on localhost on our laptop. So we’re going to switch it over
to http:// and then type into this field localhost. And then click Create
Client ID. Next, we’re going to need to
make one little tweak to this. We’re going to need to set the
port because the Java quick start uses port 8080
by default. So we’ll go in here and add
:8080, making the redirect URI http://localhost
:8080/oauth2callback. We’ll click Update, and we’re
all set for configuration. So we’ll copy the client ID. And we will set it
in this file. And then we’re going to grab
the client secret two lines below and also add
it to this file. We’re going to save our file. And our configuration
is all set. Next, we’re going to build and
start our quick start project. The Java quick start uses
Maven for dependency management and build. And it also uses a jetty
plugin for execution. So you need one command to start
this up– mvn jetty:run. So we’re going to press Enter,
fire that command off. And this may run a little bit
longer on your system. But I already have all
the dependencies. We can see that it
has started up. So let’s take a look
in a web browser. Go to localhost port 8080. The Glassware is going to
ask for permissions. You can click Accept and allow
the quick start project to start working with your Glass. And right away, it inserts a
welcome message, which has already been delivered
to my Glass. You can click these buttons
below to do some other functions, like insert a
picture of Chipotle. And that’s it. That’s all you need to
do to get started. From here, you can modify the
quick start project to add your own features and functions
and just use as a foundation for your interesting
project. Thanks a lot for watching me
guide you through the Java quick start. I look forward to
what you create.

Leave a Reply

Your email address will not be published. Required fields are marked *