<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Allen Walker</title>
    <description>The latest articles on DEV Community by Allen Walker (@allenwalker3).</description>
    <link>https://dev.to/allenwalker3</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1144951%2Fd1b344c5-eca7-4a37-97fe-da817159e4b6.jpeg</url>
      <title>DEV Community: Allen Walker</title>
      <link>https://dev.to/allenwalker3</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/allenwalker3"/>
    <language>en</language>
    <item>
      <title>How to store google api key as secret with expo</title>
      <dc:creator>Allen Walker</dc:creator>
      <pubDate>Tue, 03 Oct 2023 22:03:02 +0000</pubDate>
      <link>https://dev.to/allenwalker3/how-to-store-google-api-key-as-secret-with-expo-5egg</link>
      <guid>https://dev.to/allenwalker3/how-to-store-google-api-key-as-secret-with-expo-5egg</guid>
      <description>&lt;p&gt;If your react native expo application needs to access google services (such as google maps) you will need to create a google api key. The problem is this api key must remain hidden from the public or you risk receiving a large unannounced bill from Google.&lt;/p&gt;

&lt;p&gt;You also do not want the api key embedded in the client application as this can be extracted by a determined hacker.&lt;/p&gt;

&lt;p&gt;Fortunately this is pretty easy.&lt;/p&gt;

&lt;p&gt;Open a terminal and enter&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;eas init&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is will generate an app.json file or if you already have one, it will add &lt;code&gt;extra.eas.projectId&lt;/code&gt; to app.json&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rename your app.json file to app.config.js. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now edit app.config.js, it should something like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z-YVU0iy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z73phl9jm3aft0ny8g93.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z-YVU0iy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z73phl9jm3aft0ny8g93.jpg" alt="app.config.js" width="800" height="1117"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First notice line 1. Since this is a js file we must export the json. Add &lt;code&gt;export default {...}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now note line 40: &lt;code&gt;"apiKey": process.env.GOOGLE_SERVICES_API&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;GOOGLE_SERVICES_API is the secret variable we must now create on expo.dev&lt;/p&gt;

&lt;p&gt;Login to your expo.dev account, click secrets, and add the new variable &lt;code&gt;GOOGLE_SERVICES_API&lt;/code&gt; and set the value to your google api key.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hlRdzUCr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ayoc8xggq0dqr7ens1h.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hlRdzUCr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ayoc8xggq0dqr7ens1h.jpg" alt="Expo.dev secrets" width="800" height="608"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go back to your terminal and type&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; &lt;code&gt;eas secret:list&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;you should see something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Secrets for this account and project:
ID          30af395a-70bb-4b33-afe7-xxxxxxxxxxx
Name        GOOGLE_SERVICES_API
Scope       project
Type        STRING
Updated at  Oct 03 11:29:30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it! Now you can checkin your files to a public repository with no worries of a hacker exploiting your google api key.&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
