<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>gcloud Archives - Pietari Heino&#039;s personal website</title>
	<atom:link href="https://www.extreg.com/blog/tag/gcloud/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.extreg.com</link>
	<description></description>
	<lastBuildDate>Sun, 03 Dec 2017 17:52:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.6.7</generator>
<site xmlns="com-wordpress:feed-additions:1">99365322</site>	<item>
		<title>GCS Service Account private key not working from env?</title>
		<link>https://www.extreg.com/blog/2017/12/gcs-service-account-private-key-not-working-env/</link>
					<comments>https://www.extreg.com/blog/2017/12/gcs-service-account-private-key-not-working-env/#comments</comments>
		
		<dc:creator><![CDATA[Pietari]]></dc:creator>
		<pubDate>Sun, 03 Dec 2017 17:45:03 +0000</pubDate>
				<category><![CDATA[random]]></category>
		<category><![CDATA[env]]></category>
		<category><![CDATA[gcloud]]></category>
		<category><![CDATA[gcloud node]]></category>
		<category><![CDATA[gcs]]></category>
		<category><![CDATA[gcs service account]]></category>
		<category><![CDATA[pem routines error]]></category>
		<category><![CDATA[pem_read_bio: no start line]]></category>
		<category><![CDATA[private key environment variable]]></category>
		<category><![CDATA[service account private key]]></category>
		<guid isPermaLink="false">https://extreg.com/?p=259</guid>

					<description><![CDATA[<p>The sole purpose of this post is to help people who are googling for the same issue. It took me quite a while before finding the answer. TL;DR: check out this answer. If you&#8217;re trying to initialize gcloud, google-cloud-node, or whatever Google Cloud related npm package on your NodeJS project using secrets stored in environment ... <span class="more"><a class="more-link" href="https://www.extreg.com/blog/2017/12/gcs-service-account-private-key-not-working-env/">[Read more...]</a></span></p>
<p>The post <a rel="nofollow" href="https://www.extreg.com/blog/2017/12/gcs-service-account-private-key-not-working-env/">GCS Service Account private key not working from env?</a> appeared first on <a rel="nofollow" href="https://www.extreg.com">Pietari Heino&#039;s personal website</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The sole purpose of this post is to help people who are googling for the same issue. It took me quite a while before finding the answer. TL;DR: check out this <a href="https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1173#issuecomment-199183259">answer</a>.</p>
<p>If you&#8217;re trying to initialize gcloud, google-cloud-node, or whatever Google Cloud related npm package on your NodeJS project using secrets stored in environment variables (specifically <strong>Service Account private key!</strong>) and you&#8217;re running into this problem:</p>
<p style="padding-left: 10px;"><strong>[Error: Could not authenticate request</strong><br />
<strong>error:0906D06C:PEM routines:PEM_read_bio:no start line]</strong></p>
<p>This is most likely caused by either of these problems (or both):</p>
<p>1. You touched the beginning and end of the private key string, leave them intact! So the string *has to* look like this:</p>
<p><code style="padding-left: 10px;">-----BEGIN PRIVATE KEY-----\n[base64encoded...]==\n-----END RPIVATE KEY-----\n</code></p>
<p>2. When you read in the private key in your NodeJS server application, remember check it&#8217;s not amended in any way. If you look at the private key string that&#8217;s included in the service account json provided by Google Cloud Console&#8217;s IAM manager, it has got a multitude of <em><strong>\n </strong></em>every here and there. Those are converted into <strong>\\n</strong>&#8216;s when the private key is accessed from the environment variable and they have to be put back in order. So basically do something like this:</p>
<p><code style="padding-left: 10px;">const privKey = process.env.PRIVATE_KEY.replace(/\\n/g, '\n');</code></p>
<p>That&#8217;s it.</p>
<p>The post <a rel="nofollow" href="https://www.extreg.com/blog/2017/12/gcs-service-account-private-key-not-working-env/">GCS Service Account private key not working from env?</a> appeared first on <a rel="nofollow" href="https://www.extreg.com">Pietari Heino&#039;s personal website</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.extreg.com/blog/2017/12/gcs-service-account-private-key-not-working-env/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">259</post-id>	</item>
	</channel>
</rss>
