Skip to content

Google oAuth2 and Google Sheets example implementation in Elixir and Phoenix Framework

Notifications You must be signed in to change notification settings

coletiv/google_sheets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoogleSheets

This repository was done to go along with this article.

Google API and Google Sheets API Example Integration

To start your Phoenix server:

  • Install dependencies with mix deps.get
  • Create and migrate your database with mix ecto.setup
  • Install Node.js dependencies with npm install inside the assets directory
  • Start Phoenix endpoint with mix phx.server
  • If you need to run in debug mode run iex -S mix phx.server

To run the app

  • Get your OAuth2.0 credentials for the Google Console (don't forget to activate Google Drive API and Google Sheets API in your project)
  • Env vars to declare: GOOGLE_CLIENT_ID={your_google_client_id} GOOGLE_CLIENT_SECRET={your_google_client_secret} GOOGLE_CONSENT_REDIRECT_URI={your_server_host}/api/consent GOOGLE_CLIENT_STATE={Generate a random secret to validate if the outside requests are coming from Google} DEFAULT_PERMISSION_EMAIL={The google email drive account where you want to receive the created spreadsheet}
  • After setting all the environment variables and sourcing them, call the function GoogleSheets.Requests.create_spreadsheet("YOUR_SPREADSHEET_NAME") (run server in debug mode) If you are prompted for a consent url, click on it and allow the permissions. You can change the permissions in the scope of auth.ex file. If you are prompted with a {:ok, SPREADSHEET_ID} go to the google drive of the DEFAULT_PERMISSION_EMAIL and you'll find the newly generated sheet there!

About

Google oAuth2 and Google Sheets example implementation in Elixir and Phoenix Framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published