Drivex is a Google Drive API Elixir wrapper library. Here is an example:
iex> GoogleDrive.list()
%{"files" => [%{"id" => "1tDgypK1qrcg0oule4Cxxxxxxxy0L7CwN82G0JxC8",
"kind" => "drive#file",
"mimeType" => "application/vnd.google-apps.spreadsheet", "name" => "spreadsheet1"},
%{"id" => "0B8yV3717Z-lxxxxxxxxxDaVE", "kind" => "drive#file",
"mimeType" => "application/vnd.google-apps.folder", "name" => "folder1"},
...
iex>
See the online documentation.
- Add to your
mix.exs
file:
def deps do
[
{ :drivex, "~> 0.0.2" }
]
end
-
Create or select a project at Google Drive API enabler wizard. Click Continue. Click Go to credentials.
-
Select Other non-UI, Click Application data, Click No, I have not used., Click Required credentials.
-
Input Service account name, Select Porject - Owner. Click next, Start download JSON automatically. Rename it to client_secret.json and move to
config
folder. -
Click Manage service accounts, Edit service account, Click Enable G Suite domain wide delegation.
-
Browse Google Drive and set Collaboration Settings to any folder on add service account id(like [email protected]).
-
Add to your
config.exs
file:
config :goth,
json: "./config/client_secret.json" |> File.read!
- Input following, It's success when listed Google Drive folders & files.
mix desp.get
iex -S mix
iex> GoogleDrive.list()
%{"files" => [%{"id" => "1tDgypK1qrcg0oule4Cxxxxxxxy0L7CwN82G0JxC8",
"kind" => "drive#file",
"mimeType" => "application/vnd.google-apps.spreadsheet", "name" => "spreadsheet1"},
%{"id" => "0B8yV3717Z-lxxxxxxxxxDaVE", "kind" => "drive#file",
"mimeType" => "application/vnd.google-apps.folder", "name" => "folder1"},
...
This project is licensed under the terms of the Apache 2.0 license, see LICENSE.