首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ionic 2安全存储Google Maps Api密钥

Ionic 2安全存储Google Maps Api密钥
EN

Stack Overflow用户
提问于 2018-03-19 20:47:21
回答 1查看 472关注 0票数 1

我有一个使用cordova google maps plugin的离子应用程序。

在我的config.xml

代码语言:javascript
复制
<plugin name="cordova-plugin-googlemaps" spec="^2.1.1">
    <variable name="API_KEY_FOR_IOS" value=“$AFLKSDJFSD" />
    <variable name="LOCATION_WHEN_IN_USE_DESCRIPTION" value="Show your location on the map" />
    <variable name="LOCATION_ALWAYS_USAGE_DESCRIPTION" value="Trace your location on the map" />
</plugin>

我假设在config.xml中存储api密钥是不安全的,但这可能是错误的。

是否有在config.xml中存储敏感变量的最佳实践

谢谢

EN

回答 1

Stack Overflow用户

发布于 2018-03-19 22:50:52

您可以使用secure storage来实现此目的。

代码语言:javascript
复制
import { SecureStorage, SecureStorageObject } from '@ionic-native/secure-storage';

constructor(private secureStorage: SecureStorage) { }

...
//
this.secureStorage.create('your_storage_name')
  .then((storage: SecureStorageObject) => {
     //get the key from storage
     storage.get('google_api_key')
       .then(
         data => console.log(data),
         error => console.log(error)
     );
     //set the key into storage
     storage.set('key', 'value')
       .then(
        data => console.log(data),
         error => console.log(error)
     );
  });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49363375

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档