A Clojure library for calling Google APIs; sheets, drive, bigquery, and so on.
EPL-2.0 License
A Clojure library for calling Google APIs; gsheets, drive, bigquery, and so on.
deprecated This project has been replaced by happyapi.google
This project is the successor to HappyGAPI (deprecated),
the oauth2 and generation were moved to HappyAPI.
The new artifact name io.github.timothypratley/happygapi2
was introduced to avoid breaking changes.
HappyGAPI2 is a bunch of generated functions (as code, not macros) for calling GAPI, so that your editor can help you (autocomplete, help documentation, and arg checking).
Add the dependency to the project file:
Require happygapi2.<<api>>
in the code:
(ns my.ns
(:require [happygapi2.sheets :as sheets]))
(sheets/spreadsheets-get "SPREADSHEET-ID")
To create an app in the Google Console, follow Setting up OAuth 2.0. When setting up the app credentials, add http://localhost/redirect to the authorized redirect URIs, and add yourself as a test user.
There are two methods for obtaining a token:
secret.json
from the Google Console.service.json
key file.The happy.oauth2-credentials
namespace provides a convenient way to
manage authorization.
By default, it tries to read secret.json
or service.json
from disk in the current directory.
You can pass in configuration map of the same shape instead.
happy.oauth2-credentials
stores tokens on disk.
If you want to use HappyGAPI in a web app, you should instead store and fetch tokens from your database.
This can be done by calling init!
with a fetch
and store
function, or by creating your own implementation of auth!
.
The happy.oauth2-capture-redirect
namespace provides a listener to capture a code when the user is redirected to your site from the oauth2 provider.
If you use it, you will need to include ring as a dependency.
Web applications should instead define a route to capture the code.
The happy.oauth2
namespace provides generic functions to support oauth2 authorization so that you can assemble only the parts you need.
Issues, pull requests, and suggestions are welcome.
Building pulls down the latest schema. You can build it yourself if this library has not been updated in a while. Please email me if you'd like me to push an updated version.
The source code here was generated by another project: HappyAPI
See deps.edn
Copyright © 2020 Timothy Pratley
This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at https://www.gnu.org/software/classpath/license.html.