Created
December 26, 2016 15:43
-
-
Save rootux/07be18f0b75127b7357ece86dc1132a2 to your computer and use it in GitHub Desktop.
Env variable version of https://github.com/google/google-auth-library-ruby/tree/master/lib/googleauth/stores
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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