Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/d6y/heist

An experiment to see if we can get away with a less painful way of accessing the Google APIs.
https://github.com/d6y/heist

Last synced: about 1 month ago
JSON representation

An experiment to see if we can get away with a less painful way of accessing the Google APIs.

Awesome Lists containing this project

README

        

> An experiment to see if we can get away with a less painful way of accessing the Google APIs.

[cats]: http://non.github.io/cats//index.html

# Example

``` scala
val credentials = ???

import spreadsheet._

val prog = for {
sheet <- openSheet("UK Jan Rainfall")
work <- openWorksheet(sheet, 0)
rows <- rows(work)
xs <- cells(rows)
} yield xs

val interp = new interpreter.GoogleClientInterpreter(credentials)

val result = interp.run(prog)
println(result.toList)
// List(1766, 4.4, 1767, 92.7, 1768, 109.2, ...)
```

# Status

Not even alpha. Do not use this. I don't even use it yet. The rows/cells language is terrible and will change. In fact, I'm more likely to look at Calendar and Contacts first. Keep away. :skull:

# Getting Started

You need to:

- Build Cats (check it out, and `sbt publish-local`)
- Register an application is the Google Console (see _API Secrets_ below)
- Run the _main.scala_
- Re-write everything.

## API Secrets

To run this you need to enable the Google Drive APIs, and get a set of secrets for this application. You will then be able to run the application and request permissions to access a user's data (documents, calendar etc).

## Configure a New Application

Go to https://console.developers.google.com/project

1. Create a project (I called one heist)
1. In APIs & auth > APIs, search for Drive APIs and Enable
1. In Credentials, Create new Client ID and then you have options... pick "Installed Application" for now (web application should work too, but I've not yet tried it with this code base)
1. Either way, you'll end up with some secrets you can download as JSON. Save the file contents as _private/client_secret.json_.

Now when you run the application you'll be prompted to visit a URL and grant your application permissions to access your data.

## `Auth.simple`

A utility, `heist.Auth.simple` uses the _private_ folder to persist authentication tokens.

Assuming you have a _private/client_secret.json_ file already, running `Auth.simple` will prompt you to visit a URL to get an access code. This is automatically exchanged for an access token which is stored on disk and reused in future requests.

# Reference Material

* [Google Java Client latest API javadoc](http://javadoc.google-api-java-client.googlecode.com/hg/latest/index.html)

## GData

Google Spreadsheets uses the old GData APIs and has not yet been [migrated](https://github.com/google/gdata-java-client/blob/wiki/MigratingToGoogleApiJavaClient.md).

* [GData API](https://developers.google.com/gdata/javadoc/)

* [Google Sheets API](https://developers.google.com/google-apps/spreadsheets/)