I'm using the googleapi's Flutter package and to use the Google Drive API, I need to put in credentials. My question is, how can I securely store them in my app so when I publish my app, they can't be taken. I found a cool package, flutter_secure_storage but to use it, I need to put all of my values into the secure storage. So how can I do that? I was thinking of using something like this, but I'm not sure. It would be great if someone could put me in the right direction as to how to do this by the book so to speak.
To further explain, I don't want to have my sensitive information in a file such as main.dart
as a variable to put into storage (if it isn't there already).
HMAC Authentication is common for securing public APIs whereas Digital Signature is suitable for server-to-server two way communication. OAuth on the other hand is useful when you need to restrict parts of your API to authenticated users only.
API keys aren't as secure as authentication tokens (see Security of API keys), but they identify the application or project that's calling an API. They are generated on the project making the call, and you can restrict their use to an environment such as an IP address range, or an Android or iOS app.
Flutter provides various security and authentication plugins. By integrating a sign-in plugin, developers can easily add an authentication check to an app. > Leaking of sensitive data — Nowadays mobile apps contain all kinds of sensitive data, from IDs, passwords, PINs, financial details, and more.
You can do this by using the flutter_dotenv package.
Create a .env
file in the root of your project:
GOOGLE_API = API_KEY
Add the .env
file to your assets bundle in pubspec.yaml
assets:
- .env
Add the .env
file as an entry in your .gitignore
if it isn't already
.env*
Access variables from .env
throughout the application
DotEnv().env['GOOGLE_API'];
Read more on how to install and use the package here: flutter_dotenv
I advise you to create a database to store your keys. You can set up a small backend connected to your base that you contact, So you can implement all the security you want. This is the safest way
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With