googleapis/elixir-google-api

The task "google_apis.auth" could not be found

matheuscamarques opened this issue · 3 comments

The task "google_apis.auth" could not be found

+1, am also experiencing this issue. It seems that none of the individual google_api_XXXX mix dependencies come with this mix task, but it is clearly available in this repo. Is there a recommended way to include this mix task / a recommended dependency to point at?

I managed to get something to work by copying this task into my local project, as well as the OAuthStrategy module that it uses... I got as far as the redirect from the OAuth flow to localhost and then it failed because I don't have a server running on localhost... makes me wonder if this mix task was ever meant to be used outside of development on this library.

I have also tried pointing at this github repo in my mix.exs to get the entire project, and cannot get past configuring the the google oauth client when trying to run the task:

defmodule GoogleDriveUploader.MixProject do
  use Mix.Project

  def project do
    [
      app: :google_drive_uploader,
      version: "0.1.0",
      elixir: "~> 1.14",
      start_permanent: Mix.env() == :prod,
      deps: deps()
    ]
  end

  # Run "mix help compile.app" to learn about applications.
  def application do
    [
      extra_applications: [:logger]
    ]
  end

  # Run "mix help deps" to learn about dependencies.
  defp deps do
    [
      {:google_apis, git: "https://github.com/googleapis/elixir-google-api"},
      {:goth, "~> 1.2.0"},
      {:oauth2, "~> 0.9"}
    ]
  end
end
# config/config.ex
import Config

config :google_apis, :oauth_client, System.get_env("GOOGLE_OAUTH_CLIENT")
config :google_apis, :oauth_secret, System.get_env("GOOGLE_OAUTH_SECRET")
❯ mix google_apis.auth https://www.googleapis.com/auth/drive
Please set the Google OAuth client id

Ok, last update. I was able to get things working by:

  1. pointing my mix dependency at this repo instead of using the individual client repos
  2. specify a config/config.exs as I did above <-- IMPORTANT: should be .exs not .ex 🤦
  3. run mix google_apis.auth https://www.googleapis.com/auth/drive

I still think that this mix tasks should be included in all client hex packages if it's in the main README.md for all google_api clients though...