A
A
Alexander Kusak2018-12-19 17:38:14
JavaScript
Alexander Kusak, 2018-12-19 17:38:14

Why does the VK JavaScript SDK throw an error when sending a notification via secure.sendNotification?

Why does the VK JavaScript SDK throw an error when sending a notification via secure.sendNotification ?

VK.api("utils.getServerTime", {"v":"5.92"}, (data) => {
      VK.api("secure.sendNotification", {"user_ids": ids ? ids : App.Data.Player.id, "user_id": App.Data.Player.id, "message": msg ? msg : "Test native message", "timestamp": data.response, "client_secret": params.get('access_token'), "v":"5.92"}, (data) => {
        console.log(data);
        if(data.response) {
          showInfoPopup("Отправлено оповещение!");
        }
      });
    });

Error response:
error_code: 4
error_msg: "Incorrect signature"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2018-12-19
@McFree

secure.*methods can only be called from the server. You are trying through client-side JS.
What they write about securemethods:

This section provides administrative methods that can be called on behalf of an application using a third-party server. To use these methods, a special authorization scheme must be applied .
In addition to the standard parameters specified in the description of the methods, the client_secret parameter must be added to the request, containing the value from the "Secure key" field in the application settings.
Please note that test mode is not supported when working with secure methods!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question