# Why is there no earth icon after I configured the Google Translator API?

**URL:** <https://meta.discourse.org/t/why-is-there-no-earth-icon-after-i-configured-the-google-translator-api/280405>\
**Category:** Support\
**Tags:** translator\
**Created:** [September 28, 2023, 9:49am UTC](https://meta.discourse.org/t/why-is-there-no-earth-icon-after-i-configured-the-google-translator-api/280405 "2023-09-28T09:49:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guo\_SpicyGum](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/guo_spicygum/32/319983_2.png) [@Guo\_SpicyGum](https://meta.discourse.org/u/Guo_SpicyGum)\
**Post date:** [September 28, 2023, 9:49am UTC](https://meta.discourse.org/t/why-is-there-no-earth-icon-after-i-configured-the-google-translator-api/280405/1 "2023-09-28T09:49:58Z")

</div>

Why is there no earth icon after I configured the Google Translator API?

```plaintext
root@talk:/data/discourse# ./launcher enter app
x86_64 arch detected.
WARNING: containers/app.yml file is world-readable. You can secure this file by running: chmod o-rwx containers/app.yml
root@talk-app:/var/www/discourse# rails c
[1] pry(main)> DiscourseTranslator::Google.detect(Post.last)
DiscourseTranslator::TranslatorError: {"error"=>{"code"=>403, "message"=>"Requests from referer <empty> are blocked.", "errors"=>[{"message"=>"Requests from referer <empty> are blocked.", "domain"=>"global", "reason"=>"forbidden"}], "status"=>"PERMISSION_DENIED", "details"=>[{"@type"=>"type.googleapis.com/google.rpc.ErrorInfo", "reason"=>"API_KEY_HTTP_REFERRER_BLOCKED", "domain"=>"googleapis.com", "metadata"=>{"service"=>"translate.googleapis.com", "consumer"=>"projects/390801787023"}}]}}
from /var/www/discourse/plugins/discourse-translator/services/discourse_translator/google.rb:134:in `result'

```

---

<div class="post-metadata">

**Author:** ![Guo\_SpicyGum](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/guo_spicygum/32/319983_2.png) [@Guo\_SpicyGum](https://meta.discourse.org/u/Guo_SpicyGum)\
**Post date:** [September 28, 2023, 1:16pm UTC](https://meta.discourse.org/t/why-is-there-no-earth-icon-after-i-configured-the-google-translator-api/280405/2 "2023-09-28T13:16:03Z")

</div>

![image](https://global.discourse-cdn.com/meta/original/4X/c/1/b/c1ba9e1d450126530943f3eb29a463be719c6a18.png)  
 ![image](https://global.discourse-cdn.com/meta/original/4X/2/b/f/2bffae63b105539a45929f5702b050aa469688d5.png)  
Is there anyone who can support me?

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [September 28, 2023, 4:45pm UTC](https://meta.discourse.org/t/why-is-there-no-earth-icon-after-i-configured-the-google-translator-api/280405/3 "2023-09-28T16:45:21Z")

</div>

> [@Guo\_SpicyGum](#):
>
> `:TranslatorError: {"error"=>{"code"=>403,`

It looks like you have not supplied a valid key for accessing the translator. I would check that you have supplied payment and re-copy or re-generate the key.

---

<div class="post-metadata">

**Author:** ![Guo\_SpicyGum](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/guo_spicygum/32/319983_2.png) [@Guo\_SpicyGum](https://meta.discourse.org/u/Guo_SpicyGum)\
**Post date:** [October 7, 2023, 1:04pm UTC](https://meta.discourse.org/t/why-is-there-no-earth-icon-after-i-configured-the-google-translator-api/280405/6 "2023-10-07T13:04:15Z")

</div>

okay, is my request test method correct?

```plaintext
 DiscourseTranslator::Google.detect(Post.last)

```

I have provided the correct API Key, but still get the error:

```plaintext
[8] pry(main)> DiscourseTranslator::Google.detect(Post.last)
DiscourseTranslator::TranslatorError: {"error"=>{"code"=>403, "message"=>"Requests from referer <empty> are blocked.", "errors"=>[{"message"=>"Requests from referer <empty> are blocked.", "domain"=>"global", "reason"=>"forbidden"}], "status"=>"PERMISSION_DENIED", "details"=>[{"@type"=>"type.googleapis.com/google.rpc.ErrorInfo", "reason"=>"API_KEY_HTTP_REFERRER_BLOCKED", "domain"=>"googleapis.com", "metadata"=>{"consumer"=>"projects/390801787023", "service"=>"translate.googleapis.com"}}]}}
from /var/www/discourse/plugins/discourse-translator/services/discourse_translator/google.rb:134:in `result'

```

---

<div class="post-metadata">

**Author:** ![Guo\_SpicyGum](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/guo_spicygum/32/319983_2.png) [@Guo\_SpicyGum](https://meta.discourse.org/u/Guo_SpicyGum)\
**Post date:** [October 9, 2023, 3:35pm UTC](https://meta.discourse.org/t/why-is-there-no-earth-icon-after-i-configured-the-google-translator-api/280405/8 "2023-10-09T15:35:14Z")

</div>

I filled in the google translator api key, but it doesn’t work properly, please help solve it!

 ![image](https://global.discourse-cdn.com/meta/original/4X/3/9/7/397237cd1dbacc06846d5dd07d44953c13255008.png)  
 ![image](https://global.discourse-cdn.com/meta/original/4X/4/4/6/446343d852fbd54be31e7ad43c9ac7b9f9e320ac.png)

```plaintext
root@talk:/data/discourse# ./launcher enter app
x86_64 arch detected.
WARNING: containers/app.yml file is world-readable. You can secure this file by running: chmod o-rwx containers/app.yml
root@talk-app:/var/www/discourse# rails c
[1] pry(main)> DiscourseTranslator::Google.detect(Post.last)
DiscourseTranslator::TranslatorError: {"error"=>{"code"=>403, "message"=>"Requests from referer <empty> are blocked.", "errors"=>[{"message"=>"Requests from referer <empty> are blocked.", "domain"=>"global", "reason"=>"forbidden"}], "status"=>"PERMISSION_DENIED", "details"=>[{"@type"=>"type.googleapis.com/google.rpc.ErrorInfo", "reason"=>"API_KEY_HTTP_REFERRER_BLOCKED", "domain"=>"googleapis.com", "metadata"=>{"service"=>"translate.googleapis.com", "consumer"=>"projects/390801787023"}}]}}
from /var/www/discourse/plugins/discourse-translator/services/discourse_translator/google.rb:134:in `result'

```

my request test method correct?

---

<div class="post-metadata">

**Author:** ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)\
**Post date:** [October 9, 2023, 6:11pm UTC](https://meta.discourse.org/t/why-is-there-no-earth-icon-after-i-configured-the-google-translator-api/280405/9 "2023-10-09T18:11:49Z")

</div>

You have defined website restrictions, and the API expects to see a `Referer` header in the API request, which seems explicitly required here:

[https://github.com/discourse/discourse-translator/blob/main/services/discourse\_translator/google.rb#L119C9-L124](https://github.com/discourse/discourse-translator/blob/main/services/discourse_translator/google.rb#L119C9-L124)

To fix it, you would probably need the following:

```ruby
headers: {
    "Content-Type" => "application/x-www-form-urlencoded",
    "Referer" => Discourse.base_url
  }

```

In other words, the issue is not caused by your end.

What you can do is either:

- Try restriction by IP
- Disable the restriction until it’s fixed in the plugin

Hope that helps!

---

<div class="post-metadata">

**Author:** ![Guo\_SpicyGum](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/guo_spicygum/32/319983_2.png) [@Guo\_SpicyGum](https://meta.discourse.org/u/Guo_SpicyGum)\
**Post date:** [October 13, 2023, 3:20pm UTC](https://meta.discourse.org/t/why-is-there-no-earth-icon-after-i-configured-the-google-translator-api/280405/10 "2023-10-13T15:20:53Z")

</div>

Thank you very much for your help, with the above I have been able to pass the test successfully. But I found that I still have the earth translation icon.

```plaintext
root@talk-app:/var/www/discourse/plugins/discourse-translator/services/discourse_translator# rails c
[1] pry(main)> DiscourseTranslator::Google.detect(Post.last)
=> "en"
[2] pry(main)> 

```
