AlexaAndroid icon indicating copy to clipboard operation
AlexaAndroid copied to clipboard

API Key does not exist or is incorrect

Open tonyw05 opened this issue 6 years ago • 9 comments

I know the API_key.txt is in the correct spot and I can view it in android studios. I know this is the correct code. It is the correct MD5 and SHA256 as far as I know and the correct package name. I could use f=some help and would be happy to provide any more information that you may deem necessary to help. Here is my logcat after launching the app on an emulatore:

08-03 10:20:30.100 3822-3822/? E/AuthorizationHandler: Unable to Use Amazon Authorization Manager. APIKey is incorrect or does not exist. Does assets/api_key.txt exist in the main application? java.lang.IllegalArgumentException: Invalid API Key at com.amazon.identity.auth.device.authorization.api.AmazonAuthorizationManager.(AmazonAuthorizationManager.java:119) at com.willblaschko.android.alexa.AuthorizationManager.(AuthorizationManager.java:56) at com.willblaschko.android.alexa.AlexaManager.(AlexaManager.java:70) at com.willblaschko.android.alexa.AlexaManager.getInstance(AlexaManager.java:106) at com.willblaschko.android.alexa.AlexaManager.getInstance(AlexaManager.java:90) at com.willblaschko.android.alexa.service.DownChannelService.onCreate(DownChannelService.java:57) at android.app.ActivityThread.handleCreateService(ActivityThread.java:3532) at android.app.ActivityThread.access$1300(ActivityThread.java:199) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1666) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

tonyw05 avatar Aug 03 '18 14:08 tonyw05

Are you using a debug keystore or a release keystore?

ihavenoface5 avatar Aug 03 '18 14:08 ihavenoface5

@ihavenoface5 How can I check that? Sorry I'm somewhat new.

tonyw05 avatar Aug 03 '18 14:08 tonyw05

No worries. When you generated your MD5 / SHA256 key you specified a keystore file. This keystore is used to sign your APK file.

You built your APK file by either:

  1. Selecting build APK (or the play button in Android Studio). This will use the debug keystore.
  2. Selecting generate signed APK which will build an APK signed with a keystore you specify.

ihavenoface5 avatar Aug 03 '18 14:08 ihavenoface5

@ihavenoface5 Gotcha.. I actually ran these lines of code in a terminal: keytool -genkey -v -keystore keystore.jks -alias androiddebugkey -keyalg RSA -sigalg SHA1withRSA -keysize 2048 -validity 10000

keytool -list -v -alias androiddebugkey -keystore keystore.jks

I have checked in android studios via gradle signing report and got the same MD5 and SHA 256.

tonyw05 avatar Aug 03 '18 15:08 tonyw05

Double check a couple of things:

  1. Your package name matches what you used in your security profile.
  2. Your product ID matches the one you used when registering your Amazon product on the developer console.
    PRODUCT_ID = "interactive_conversation" should be set to the product name you specified.

ihavenoface5 avatar Aug 03 '18 15:08 ihavenoface5

@ihavenoface5 The package name under the API Key name on amazon is com.willblaschko.android.alexavoicelibrary

I have switched two instances of Product_ID to my devices product ID. Are there any more?

tonyw05 avatar Aug 03 '18 15:08 tonyw05

Nope, that should be it.

ihavenoface5 avatar Aug 03 '18 15:08 ihavenoface5

still getting the same error:/

tonyw05 avatar Aug 03 '18 15:08 tonyw05

@ihavenoface5 still getting the same error:/

tonyw05 avatar Aug 03 '18 15:08 tonyw05