R- Following Error: API returned: Request had insufficient authentication scopes

1.2k Views Asked by At

I've verified my API in RStudio after hours of trying and now I've reached another error while trying to translate a sentence. Would be grateful for any help!

I'm just trying to translate "hello" to french using googleLanguageR package -

> gl_translate("Hello", "fr")

The result I get is this -

2021-01-21 17:15:36 -- Translating text: 5 characters - 
i 2021-01-21 17:15:36 > Request Status Code:  403
Error: API returned: Request had insufficient authentication scopes.

I'm a literal beginner in the field of computing and do not understand what scopes mean here.

Thanks for the help!

2

There are 2 best solutions below

0
On

Scopes are permissions that you give to apps you use to access an API. For example, one App might have permission to read the private messages of a users, whereas another doesn't. It's similar to when an app on your phone asks for permission to use the camera, or access your contacts.

Your app is trying to do something that it doesn't have permission to do. You'll need to add the relevant scopes in whatever setting that it is where you're generating keys etc. Presumably Google Data Studio?

0
On

Okay, I found an answer.

I needed to download a json version of my key and authorize it using the code -

gl_auth("filename.json")

After doing this, I needed to make sure my API is enabled. Now, it is working perfectly!