G
G
glebvvs2019-03-03 13:29:24
API
glebvvs, 2019-03-03 13:29:24

Why can't I connect to the Yandex API?

I'm trying to connect to the Yandex API.
I log into Yandex.OAuth using the login and password that I use to log into Yandex.Webmaster.
I received the debug token and registered the application. The application was allowed access to the webmaster. In the application address I entered the url of the site from which I make requests.
Here is a preview of the application, where it is clearly indicated which Yandex services I want to connect
5c7ba9759c2da137963273.pngto, in the application settings, the fields that I fill in so that my application is allowed access to the API
5c7baad6b38f4618130446.pngThis is a browser warning that tells me that I cannot receive API resources from my site :

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.webmaster.yandex.net/v4/user/. (Reason: CORS header 'Access-Control-Allow-Origin' missing).

Here is an example request I make to get the user id:
fetch('https://api.webmaster.yandex.net/v4/user/', {
  method: 'GET',
  headers: {
    "Authorization": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  }
})
.then(response => {
  
});

What could be the problem? Am I making the wrong request or have I configured something wrong on the Yandex side?
I would be grateful if someone could point me in the right direction.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Gorbatsevich, 2019-03-03
@Nuark

Try

fetch('https://api.webmaster.yandex.net/v4/user/', {
    mode: 'no-cors'
    ...
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question