ruby_astm 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 166ef03d3cea8528d5efe22f666cee22bb95a1de
4
- data.tar.gz: d244a14412ed832aef705c62b21fd88550de4f8e
3
+ metadata.gz: 8cffd1c3c4747acf0ba2896580ce7f0deb70ee87
4
+ data.tar.gz: 9b2fb9cf2eaec011275d3fce61801a85c3679ebf
5
5
  SHA512:
6
- metadata.gz: 1b253ff46624b761763cd74754bbf56bf87eb956de54e414fc6e0e4baf75161d3915a02b8629238ae8cd4605d3cd9762e69ae379be5961632e9bafbeae53cd08
7
- data.tar.gz: 68379077bae503a51048d9de4f98922433fb6b70a3c369a56a2eef4e56437c8fb3bb5280b68d85444575cbf8e02f4ba7d51d572e463d38b9a4af19f37fc3fda4
6
+ metadata.gz: e9d56c68e915cad3ab787e71069be40739f9614196c3f4c39ec218d0c6e72ab013de7f4d68a5ccb4a3f5de0ac75aac4ff4c6073bb0a40f5f13728f1a6b9be9d5
7
+ data.tar.gz: 67cac9e7fcd16bfe312b555e48e908503151959f458c8a51f047b3099d227a7d20402917ac2b85b08be07172740d096ed6b369c34e02de874c48ae3d519d8247
@@ -9,11 +9,9 @@ class Google_Lab_Interface < Poller
9
9
 
10
10
  OOB_URI = 'urn:ietf:wg:oauth:2.0:oob'.freeze
11
11
  APPLICATION_NAME = 'Google Apps Script API Ruby Quickstart'.freeze
12
- CREDENTIALS_PATH = 'credentials.json'.freeze
13
- # The file token.yaml stores the user's access and refresh tokens, and is
14
- # created automatically when the authorization flow completes for the first
15
- # time.
16
- TOKEN_PATH = 'token.yaml'.freeze
12
+ ## these two cannot be hardcoded.
13
+ #CREDENTIALS_PATH = 'credentials.json'.freeze
14
+ #TOKEN_PATH = 'token.yaml'.freeze
17
15
  SCOPE = 'https://www.googleapis.com/auth/script.projects'.freeze
18
16
 
19
17
  SCOPES = ["https://www.googleapis.com/auth/documents","https://www.googleapis.com/auth/drive","https://www.googleapis.com/auth/script.projects","https://www.googleapis.com/auth/spreadsheets"]
@@ -21,6 +19,8 @@ class Google_Lab_Interface < Poller
21
19
  $service = nil
22
20
  SCRIPT_ID = "M7JDg7zmo0Xldo4RTWFGCsI2yotVzKYhk"
23
21
 
22
+ attr_accessor :credentials_path
23
+ attr_accessor :token_path
24
24
 
25
25
  ##
26
26
  # Ensure valid credentials, either by restoring from the saved credentials
@@ -29,9 +29,8 @@ class Google_Lab_Interface < Poller
29
29
  #
30
30
  # @return [Google::Auth::UserRefreshCredentials] OAuth2 credentials
31
31
  def authorize
32
-
33
- client_id = Google::Auth::ClientId.from_file(root_path + "/publisher/" + CREDENTIALS_PATH)
34
- token_store = Google::Auth::Stores::FileTokenStore.new(file: (root_path + "/publisher/" + TOKEN_PATH))
32
+ client_id = Google::Auth::ClientId.from_file(self.credentials_path)
33
+ token_store = Google::Auth::Stores::FileTokenStore.new(file: self.token_path)
35
34
  authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPES, token_store)
36
35
  user_id = 'default'
37
36
  credentials = authorizer.get_credentials(user_id)
@@ -48,8 +47,13 @@ class Google_Lab_Interface < Poller
48
47
  end
49
48
 
50
49
  ## @param[String] mpg : path to mappings file. Defaults to nil.
51
- def initialize(mpg=nil)
50
+ ## @param[String] credentials_path : the path to look for the credentials.json file, defaults to nil ,and will raise an error unless provided
51
+ ## @param[String] token_path : the path where the oauth token will be stored, also defaults to the path of the gem : eg. ./token.yaml - be careful with write permissions, because token.yaml gets written to this path after the first authorization.
52
+ def initialize(mpg=nil,credentials_path,token_path)
52
53
  super(mpg)
54
+ self.credentials_path = credentials_path
55
+ self.token_path = token_path
56
+ raise "Please provide the full path of the google oauth credentials.json file. If you don't have this file, please go to the Apps Script project, which has your google apps script, and Choose Create Credentials -> help me choose -> and use 'Calling Scripts Api from a UI based platform'. Also ensure that your script has permissions set for Drive, Sheets, and more. Lastly in the Apps script project ensure that settings -> google apps script API is ON." if self.credentials_path.nil?
53
57
  AstmServer.log("Initialized Google Lab Interface")
54
58
  $service = Google::Apis::ScriptV1::ScriptService.new
55
59
  $service.client_options.application_name = APPLICATION_NAME
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_astm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bhargav Raut
@@ -117,10 +117,8 @@ extra_rdoc_files: []
117
117
  files:
118
118
  - lib/mappings.json
119
119
  - lib/publisher/adapter.rb
120
- - lib/publisher/credentials.json
121
120
  - lib/publisher/google_lab_interface.rb
122
121
  - lib/publisher/poller.rb
123
- - lib/publisher/token.yaml
124
122
  - lib/ruby_astm.rb
125
123
  - lib/ruby_astm/astm_server.rb
126
124
  - lib/ruby_astm/frame.rb
@@ -1 +0,0 @@
1
- {"installed":{"client_id":"555057029489-sel4u1t4tnv3qicdhsssp9phn3r8tvrj.apps.googleusercontent.com","project_id":"project-id-4907840994004404941","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://www.googleapis.com/oauth2/v3/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"L6DjrWGteAcwJwh7YdfzYwDp","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}}
@@ -1,2 +0,0 @@
1
- ---
2
- default: '{"client_id":"555057029489-sel4u1t4tnv3qicdhsssp9phn3r8tvrj.apps.googleusercontent.com","access_token":"ya29.GlxjBtK4IVi08eyrCDI6WaEgkZnjhNK7wvJIw8vd7PzzfLiMfuphIlZFk4t8UUMSROqQIsBw7RQXTifEXE2FDjvjdLoeEr-sDj1xHVifr53_V-ZcJlbOXBCUexjxTQ","refresh_token":"1/SPwjKXMExoiU43WCJxPJYPd2cj0Hhb1Ms2ONe3KgIIs","scope":["https://www.googleapis.com/auth/documents","https://www.googleapis.com/auth/drive","https://www.googleapis.com/auth/script.projects","https://www.googleapis.com/auth/spreadsheets"],"expiration_time_millis":1543480295000}'