Skip to content

Instantly share code, notes, and snippets.

@rootux
Created December 26, 2016 15:43
Show Gist options
  • Save rootux/07be18f0b75127b7357ece86dc1132a2 to your computer and use it in GitHub Desktop.
Save rootux/07be18f0b75127b7357ece86dc1132a2 to your computer and use it in GitHub Desktop.
require 'googleauth/stores/file_token_store'
require 'googleauth/token_store'
# Implementation of google auth storage backed by ENV variable
# Gal Bracha
class EnvTokenStore < Google::Auth::TokenStore
@token = ''
def initialize(options = {})
@token = options
puts 'Init tokens with ' + options
end
# (see Google::Auth::Stores::TokenStore#load)
def load(id)
puts 'load token ' + id
return ENV[@token]
end
def store(id, token)
puts 'Great! Now Please set it manually in the env variable ' + @token
puts id
puts token
# @store.transaction { @store[id] = token }
end
# (see Google::Auth::Stores::TokenStore#delete)
def delete(id)
puts 'delete ' + id
puts 'Not implemented'
# @store.transaction { @store.delete(id) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment