Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add other scopes #10

Merged
merged 8 commits into from
Jun 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ If [available in Hex](https://hex.pm/docs/publish), the package can be installed

config :big_query,
bigquery_private_key_path: "path/to/private_key.json"

4. If you need ask for special scopes - configure them:

config :big_query,
bigquery_scope: "https://www.googleapis.com/auth/drive"
5 changes: 3 additions & 2 deletions lib/big_query/access_token.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ defmodule BigQuery.AccessToken do
iat = :os.system_time(:seconds)
exp = iat + 3600

bigquery_scope = Application.get_env(:big_query, :bigquery_scope, "")
claims = %{
"iss" => key_map["client_email"],
"scope" => "https://www.googleapis.com/auth/bigquery.readonly https://www.googleapis.com/auth/bigquery.insertdata https://www.googleapis.com/auth/bigquery",
"scope" => "#{bigquery_scope} https://www.googleapis.com/auth/bigquery.readonly https://www.googleapis.com/auth/bigquery.insertdata https://www.googleapis.com/auth/bigquery",
"aud" => "https://www.googleapis.com/oauth2/v3/token",
"exp" => exp,
"iat" => iat
Expand All @@ -45,4 +46,4 @@ defmodule BigQuery.AccessToken do
{:error, HTTPoison.Error.message(error)}
end
end
end
end
6 changes: 4 additions & 2 deletions lib/big_query/types/job/query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ defmodule BigQuery.Types.Query do
* timeoutMs - [Optional] How long to wait for the query to complete, in milliseconds. The query will continue running if timeoutMs is exceeded, but the initial query request will return.
* dryRun - [Optional] Don't actually execute the query.
* useQueryCache - [Optional] Whether to look for the result in the query cache.
* maximumBillingTier - [Optional] Overrides the bigquery default value for the billing tier limit
"""
defstruct kind: "bigquery#queryRequest", query: nil, maxResults: nil,
defaultDataset: nil, timeoutMs: nil, dryRun: nil, useQueryCache: nil
defaultDataset: nil, timeoutMs: nil, dryRun: nil, useQueryCache: nil, maximumBillingTier: nil

@type t :: %__MODULE__{
kind: String.t,
Expand All @@ -23,7 +24,8 @@ defmodule BigQuery.Types.Query do
defaultDataset: BigQuery.Types.DatasetReference.t | nil,
timeoutMs: non_neg_integer | nil,
dryRun: boolean | nil,
useQueryCache: boolean | nil
useQueryCache: boolean | nil,
maximumBillingTier: String.t | nil
}

end
Expand Down