I am trying to port some functionality from a Sinatra App to a Rails app. In the Sinatra app, the code works fine. When I bring the code over into Rails, it fails. I suspect it's in how I'm passing the config.pk file, but after many hours I still do not know. How can I successfully get the key from KeyUtils?
$ cd path/to/app
app $ rails c
Loading development environment (Rails 4.2.0.rc2)
2.1.2 :001 > key_file_path = Rails.root.join('config.p12').to_s
2.1.2 :002 > key_file = File.read(key_file_path)
2.1.2 :003 > passphrase = 'notasecret'
2.1.2 :004 > require 'google/api_client'
2.1.2 :005 > key = Google::APIClient::KeyUtils.load_from_pkcs12(key_file, passphrase)
ArgumentError: Invalid keyfile or passphrase
2.1.2 :006 > key = Google::APIClient::KeyUtils.load_from_pkcs12(key_file_path, passphrase)
ArgumentError: Invalid keyfile or passphrase
2.1.2 :007 > key_file.length
=> 4330
2.1.2 :008 > key_file
=> "3082 06c0 0201 0330 8206 7a06 092a 8648\n86f7 0d01 0701 a082 066b 0482 0667 3082\n0663 3082 0328 0609 2a86 4886 f70d 0107\n01a0 8203 1904 8203 1530 8203 1130 8203\n0d06 0b2a 8648 86f7 0d01 0c0a 0102 a082\n02b2 3082 02ae 3028 060a 2a86 4886 f70d\n010c 0103 301a 0414 a6bd 5765 7b62 fcbd\ncccf 4e26 [... key file abbreviated ...] 5270\n0202 0400 "
folder structure
my_rails_root_folder
|_ config.p12
I'm trying to follow this Google documentation as well: https://github.com/tpitale/legato/wiki/OAuth2-and-Google#application-code
Thanks in advance.