like (Figure
E
).
While your new project is selected, click on
Credentials on the left menu, and then select the
“OAuth consent screen” tab. You’ll need to create
a “Product name shown to users,” which can be
anything you’d like (Figure
F
).
Now select the Credentials tab, select “OAuth
client ID,” and click the “Create credentials”
pulldown. Select “Other” for Application type,
name it “Installed,” and click Create (Figure
G
).
Now you’ll be able to see it in your list of
credentials for this app. Select the “Installed”
credential. Click the Download JSON button,
and a file named something like client_
secret_90328409238409238xxxxx.json should
download to your computer (Figure
H
).
Once it’s completed downloading, rename the
file OpenSelfie.json (Figure
I
), then drag and
drop it into the /home/pi/git/TouchSelfie/scripts
directory.
7. CONNECT TOUCHSELFIE TO GOOGLE
PHOTOS
If you haven’t already, connect the camera
board to the Pi. Power up the Pi, open Terminal,
and run:
cd /home/pi/git/TouchSele/scripts
python ./photobooth_gui.py
Since this is your first time running the photo
booth interface (GUI), it doesn’t yet have the
proper credentials to connect to your Google
account. Your web browser will pop up; sign in
to Google (with the same email address and
password you used to configure everything in the
previous steps), and then it will ask you whether
your Pi photo booth can manipulate your photos
(Figure
J
).
Click on Allow, and then it will display a long
string of numbers and letters. Copy this string
and paste it into the Terminal window after the
prompt that says “Enter the Authentication Code”
(Figure
K
). Hit Enter, and if all is well your photo
booth will snap a photo and upload it to the album
you have previously configured! (Or fail if you
haven’t set it yet.)
An Album ID error will pop up, indicating that
you have not yet selected an album in your Google
photos account to send your photos to. Open
NOTE: You don’t have to explicitly enable any
additional APIs; here you’re dealing with basic
authentication and authorization which is used
by every API, and the photo APIs haven’t been
explicitly added to the console.
2. INSTALL THE REQUIRED
PLATFORMS ON THE PI
Connect the Pi to your network (Wi-Fi or
Ethernet) and type the following commands:
sudo apt-get update
sudo apt-get install python-imaging
sudo apt-get install python-gdata
sudo apt-get install python-imaging-
tk
sudo pip install --upgrade google-
api-python-client
sudo apt-get install luakit
sudo update-alternatives --cong
x-www-browser
This will provide you with a menu of browsers
to pick as the default; set it to luakit.
NOTE: We’re using luakit because Raspbian’s
default browser doesn’t work with Google 2-part
authentication.
3. DOWNLOAD THE TOUCHSELFIE SCRIPTS
Still in Terminal, run:
mkdir git
cd git
git clone https://github.com/wyolum/
TouchSele
NOTE: Be sure that for the following steps
you’re continuing to use the web browser on your
Raspberry Pi / monitor setup.
4. SET UP YOUR GOOGLE PHOTOS ALBUM
Go to google.com and create a Google account
(or use your own account if you have one already).
Then go to photos.google.com and create a new
Album. You’ll have to upload at least one photo to
create it (Figure
C
).
5. GET AN APP-SPECIFIC PASSWORD
Visit myaccount.google.com/security and enable
2-Step Verification. Then return to the same
page and click on “App passwords” to generate a
16-character application password (Figure
D
).
Write it down in a safe place. You’ll use it later to
connect your photo booth to Google Photos.
NOTE: If you lose the app password or forget
it, don’t worry; you’ll just have to generate a
new one.
6. CREATE API KEYS WITH
GOOGLE DEVELOPER
While logged in to your account, visit console.
developers.google.com. Click on Select a project
→ Create a project, and name it whatever you’d
makershed.com58
PROJECTS
C
D
F
Raspberry Pi Wi-Fi Party Photo Booth
E
G
M52_056-61_RaspPhoto_F2.indd 58 6/15/16 10:17 AM
Get Make: Volume 52 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.