As a rule, can not .
Such authentication is based on the authorization by the user of access to his identification data from a third-party source (we will call it a social network ) . And the fact of such authentication informs the site (the OAuth2 client) only that "on the social network X (provider OAuth2) this user has the identifier Y" , from which, say, the site can conclude that "we have a user with the identifier Z, we will consider it as such " (if earlier user Z on the same site indicated that it can be recognized by the XY pair, this is the so-called" link to the social network account ").
In typical authentication systems, such a user is given a session certifying him as Z on the site, and this session exists until it is no longer valid for the site (not the social network!):
- ... when explicitly destroying ("Exiting" from the site or recalling sessions by the server for external reasons)
- ... by time (the duration of sessions is usually limited)
OAuth2 is to transfer the token from the social network (through the browser ) to the site . After the transfer took place, the social network and the site interact directly and do not think about the browser .
If a person on this computer leaves the social network account , then only the social network browser connection will “break”. The site does not participate in it, and it will know about this fact only if it again explicitly asks, again initiating an OAuth2 login. Which through communication the browser-social network will try to “establish identity” and will receive a refusal, since there is no more such connection in this browser. But for this to happen, you will have to drive the user every time through the entire OAuth2 procedure, considering that the identity from the social network is really only one request. It will be approximately as if after any request the user pressed "Logout". Not very practical.
The situation is slightly different if the user withdraws the application's access to its data from the social network interface . Then the direct connection of the social network site should cease to function, which the server can learn and disable the session. But the social network, again, is not obliged to report this (according to OAuth2), and in this case the site will have to constantly poll the social network ( have we already arrived, can I still have the data?), Which is also not very practical.
verify_credentials
, where you can send previously saved user data and check the login status, for Wargaming API -/wot/auth/prolongate/
, well, etc. Everything is individual. And, as D-side noted in his answer, it is often impractical to do such checks. So decide if you really need it. - Gino Pane