Skip to content

A simple example program for beginners to get started with understanding Haskell, http-client and how to post data to Google Sheets

License

Notifications You must be signed in to change notification settings

Charles-Schleich/googlesheets-haskell-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Haskell - Google sheets Example!

A simple example program written in Haskell to update a sheet on Google Sheets! I wrote this because it can be difficult to find working examples of code to do very specific things in uncommon languages, especially if you are a beginner. Having said that, should this example not work for you, feel free to post an issue with as much info as possible. There are many ways to write this program in Haskell, this is just one to get you started.

Requirements

Google Sheets Setup

  1. Make a project on the google Developer Console. https://console.developers.google.com/

    1. Give this project google Sheets API access
  2. Add a Service Account for your project on the google Developer Console.

    1. Your Service Account needs the role of Project Editor (Edit Access To All Resources).
    2. Download your Service Account Key File, JSON format. Do not lose this file.

Should look something like this

{
  "type": "service_account",
  "project_id": "serviceWorkerID",
  "private_key_id": "<40-character-key-here>",
  "private_key": "<1732-character-key-here>",
  "client_email": "[email protected]",
  "client_id": "<clientIDkey>",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/projectName%40serviceWorkerID.iam.gserviceaccount.com"
}
  1. Put the key.json in the /config/ folder of the project

  2. Create a Google sheet (using the same Google Account that you created the Google Developer Project) and get the SheetID from it. https://docs.google.com/spreadsheets/d/<44-character-sheet-id>/

  3. Add your Service Account (service worker) to your sheet (i.e. share the sheet with [email protected]).

  4. Create a config.json, place the sheetID of your google sheet in the config, and the range you want to edit. more info on ranges can be found on the google sheets API website. Put this config.json into your /config/ folder of your project

{ "sheetID":"<44-character-sheet-id>"
, "range": "sheet1"
}

Running the Project

  • stack build
  • stack exec haskell-googlesheets-example-exe

About

A simple example program for beginners to get started with understanding Haskell, http-client and how to post data to Google Sheets

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published