简体   繁体   中英

How to store API-secrets in flutter

Is there a way to store a secret key (eg API key) in flutter?

Use-case: When registering a new user on my app I need to talk to my backend. Since I only want devices that I know to register users, this backend has only authenticated endpoints. Which means I need to have an API key to authorize the app.

I know you can store environment variables or configurations inside config file or user secrets in a encrypted database but there are a some problems with that in this case:

  • config file can be recovered with all of its content by just unzipping the apk file which means there are no real secrets there...
  • To have a secret in a database, you need to put it there first which is not possible before runtime.

I'll probably use environnement variable, and also, I'll obfuscate my Dart code. There is multiple tutorials, but i'll send you the one from the documentation: https://flutter.dev/docs/deployment/obfuscate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM