Android Question Api keys NOT FOUND google cloud platform SOLVED

gregorio_adrian_gimenez

Active Member
Licensed User
Longtime User
Hello everybody!
I created an API key in google cloud platform, but it doesn't work.
Incorporate restrictions so that it only works with the app and the SHA-1 signature.
I use it for the translation API
What could I be missing?
regards

https://www.b4x.com/android/forum/t...ed-google-cloud-platform-gcp-api-keys.107379/

B4X:
    Dim translate As Map
    translate.Initialize
    translate.Put("source",srclang)
    translate.Put("target", dst)
    Log(dst)
    Log(srclang)
    translate.Put("q", texto)
  
    Dim json As JSONGenerator
    json.Initialize(translate)
  
    Dim job As HttpJob:job.Initialize("@request.json", Me)
  
  
  

    Dim poststr As String = "https://translation.googleapis.com/language/translate/v2?key="&  API_KEY
  
    job.PostString(poststr, json.ToString)
    job.GetRequest.SetContentType("application/json; charset=utf-8")

    Wait For (job) JobDone(job As HttpJob)
    If job.Success Then
        Try
              
              
            Dim traductor As JSONParser
            Dim mapa_traductor As Map
            mapa_traductor.Initialize
            traductor.Initialize(job.GetString)
          
          
          
            Dim parser As JSONParser
            parser.Initialize(job.GetString)
            Dim root As Map = parser.NextObject
            Dim data As Map = root.Get("data")
            Dim translations As List = data.Get("translations")
            For Each coltranslations As Map In translations
                Dim translatedText As String = coltranslations.Get("translatedText")
            Next
          
          
        Catch
            Log(LastException)
        End Try
    Else
        Log(job.ErrorMessage)
    End If
    job.Release

}
}
{
"error": {
"code": 403,
"message": "Requests from this Android client application \u003cempty\u003e are blocked.",
"errors": [
{
"message": "Requests from this Android client application \u003cempty\u003e are blocked.",
"domain": "global",
"reason": "forbidden"
}
],
"status": "PERMISSION_DENIED"
}
}
 
Last edited:

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
I would suggest go step by step.

  • First remove all restrictions to the key
  • then add in the android restriction
  • then addin the SHA-1 restriction

That should give you a good idea where to look for the problem.
 
Upvote 0
Top