N
N
nurdus2018-01-28 23:36:07
In contact with
nurdus, 2018-01-28 23:36:07

How to properly authorize a user (vk) in an iframe application?

Good afternoon.
When there was a separate site (a game created for self-learning), authorization was done through passport.js on the server side (user data was stored in the site session). Now I decided to make an iframe application, but I can't figure out how to organize authorization correctly.
Now I did this (I guess it's not right): after starting the game, I call something like

VK.api('users.get', {'fields': ['photo']}, function(data) {
  user = data.response[0]
  if (user.id !== undefined) {
    let ioGame = io.connect(HOST); // io - socket.io
    ioGame.on('connect', function() {
      let profile = {
        id: user.id,
        provider: 'vkontakte',
        displayName: user.first_name + ' ' + user.last_name,
        photo: user.photo
      };
      ioGame.emit('init', profile);
    });
  }
})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-01-29
@alexr64

https://vk.com/dev/access_token

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question