Skip to content

justgigio/google-api-elixir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoogleApi Elixir

A Work In progress Google Api Client for access google services with Elixir ❤️

Available Features:

  • OAuth2 Authentication
  • Reports for AdWords with AWQL

Desired Features

  • All Reports Suported
  • All other services - Even SOAP based

Installation

Just add as dependency in mix.exs :

def deps do
  [{:google_api, github: "giovanecosta/google-api-elixir"}]
end

When available in Hex, the package can be installed by adding google_api to your list of dependencies in mix.exs:

def deps do
  [{:google_api, "~> 0.1.0"}]
end

Setup

  1. In config.exs file, add your credentials:
config :google_api, :oauth2,
  client_id: "xxxxxx-xxxxxxxxxxxxx.apps.googleusercontent.com",
  client_secret: "xxxxxxxxxoIuECX3NMH9x",

For each API you need to use, a configuration must be done like:

config :google_api, :adwords,
  developer_token: "ndnWxxxxxxxxxHpX71rQ",
  user_agent: "YourApplication",
  scope: "https://www.googleapis.com/auth/adwords"
  refresh_token: "" # Leave blank for now
  1. Run iex -S mix on your project
  2. Call GoogleApi.Setup.get_auth_url passing the desired scope (pre-configured like above). Ex.: :adwords
client = GoogleApi.Setup.get_auth_url(:adwords)
  1. Go to generated url and follow the steps to authorize
  2. After authorize, copy the current url (If everything is ok, it must have a approvalCode param)
  3. Call GoogleApi.Setup.get_token passing client var above and the url:
iex(1)> token = GoogleApi.Setup.get_token(client, "https://accounts.google.com/o/oauth2/approval/v2/approvalnativeapp?auto=true&response=code%3D4%2Fg4tC1mxxxxxxx&approvalCode=4%2Fg4tC1m9uNQxxxxxxxxWxGB3Bzv0")
"xxxxxxxxxxxYUuyvi87tyur7tuT&U8u9"
  1. Copy the token and paste in refresh_token config (once left blank)
config :google_api, :adwords,
  developer_token: "ndnWxxxxxxxxxHpX71rQ",
  user_agent: "YourApplication",
  scope: "https://www.googleapis.com/auth/adwords"
  refresh_token: "xxxxxxxxxxxYUuyvi87tyur7tuT&U8u9"

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/google_api.

About

A Elixir API Client to connect to Google Services [WIP]

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages