Using one Google Maps API key for different android applications

跟風遠走 提交于 2020-01-13 09:26:06

问题


I just generated the Google Maps API key to use in my android app. I had to provide the SHA-1 fingerprint and the package name for the application. It looked something like this:

BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:91:AF:A1:66:6E:44:5D:75;com.example.android.mapexample

As you can see I had to provide the package name for the app. So, does this mean that I need to get a different API key for different applications?

PS: Curiously, somehow, Google generated two API keys for the SHA-1 and package name combination I entered. Is this normal? And so, which one should I use?


回答1:


You can use the same keystore and the API key for different applications.

  1. Use the same key to sign your apps.
  2. Add a line for each application in the Console page.

So, something like this:

BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:91:AF:A1:66:6E:44:5D:75;com.example.android.mapexample
BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:91:AF:A1:66:6E:44:5D:75;com.example.android.anotherapp
BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:91:AF:A1:66:6E:44:5D:75;com.example.temp.lastapp

And now, you can use the same API key with all these apps.




回答2:


You can use the same SHA-1 print for different pacakages, but you'll have to make different API keys for different apps. And yes, Google will generate a new key everytime you make a request.




回答3:


Old question, but the accepted answer is against best practice. You can use the same API key, but it is best not to. From the Best Practices Docs:

Use independent API keys for different apps. This limits the scope of each key. If an API key is compromised, you can delete and revoke the impacted key without needing to update your other API keys.



来源:https://stackoverflow.com/questions/17296226/using-one-google-maps-api-key-for-different-android-applications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!