The BigQuiz app uses the People API to identify who is using it so that it can keep track of game and category scores. I could have used the Gplus api - which has an Apps Script advanced service, but I get the feeling that the People API is going to supersede the G+ API for this kind of usage. Apps Script doesn't have an advanced service for the people API, but it's JSON API is very easy to use.
You can play with the BigQuiz app here.
I want to have this displayed on the App bar
and I also need an id against which to record the user's scores in Firebase, both of which are available from the People API.
I could have accessed the people API from the client side using gapi, but I prefer to keep all my client secrets and API access on the server and also to manage all the authorization in one place (since I'll be accessing other APIS too), so I'll just access the API from the server. The App is running as the user accessing the App, so I need to follow the guidelines in Using OAuth2 when published as 'user accessing the webapp'. This means I have a one off Goa setup that looks like this, to generate an authorization and manage the token needed for the People API scope. The fileId is the Drive file id of the credentials downloaded from the developers console for my project, where I have enabled the People API. This can be deleted if you want after running once.
This is part of the BigQuiz Tracking namespace. getPlayer will fetch and get the primary values for the id, email, name and so on for the logged on user. Goa is used to retrieve an access token behind the scenes.
It's nice to get the photo returned from the API in a circular frame. The way to do it is with a rounded thick border, the same color as the App bar background
Set up the picture size in the app settings.
add an img element to hold the picture
create some css to frame it
For more like this, see Google Apps Scripts snippets. Why not join our forum, follow the blog or follow me on twitter to ensure you get updates when they are available.
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Complete Apps Script Applications > BigQuiz app >