0

I'm trying to use a restricted (to Android App Only) API key, which in turn giving me below error:

error   
code    403
message "Requests from this Android client application <empty> are blocked."
errors  
0   
message "Requests from this Android client application <empty> are blocked."
domain  "global"
reason  "forbidden"
status  "PERMISSION_DENIED"

I have added the proper Sha1 Keys for debug while restricting the key. The same functionality is working properly if the key is not restricted.

I've looked into this answer But, not sure how to add package name and SHA-1 certificate fingerprint to a request to Google in the header of each request.

Hear is my class where i do the request

import okhttp3.OkHttpClient

class CivicsHttpClient: OkHttpClient() {

    companion object {

        const val API_KEY = "" //Place your API Key Here

        fun getClient(): OkHttpClient {
            return Builder()
                    .addInterceptor { chain ->
                        val original = chain.request()
                        val url = original
                                .url()
                                .newBuilder()
                                .addQueryParameter("key", API_KEY)
                                .build()
                        val request = original
                                .newBuilder()
                                .url(url)
                                .build()
                        chain.proceed(request)
                    }
                    .build()
        }

    }

}

Many thanks.

rungene
  • 31
  • 6

0 Answers0