Gio.Socket.prototype.get_credentials

function get_credentials(): Gio.Credentials {
    // Gjs wrapper for g_socket_get_credentials()
}
  

Returns the credentials of the foreign process connected to this socket, if any (e.g. it is only supported for Gio.SocketFamily.unix sockets).

If this operation isn't supported on the OS, the method fails with the Gio.IOErrorEnum.not_supported error. On Linux this is implemented by reading the %SO_PEERCRED option on the underlying socket.

Other ways to obtain credentials from a foreign peer includes the Gio.UnixCredentialsMessage type and Gio.UnixConnection.prototype.send_credentials / Gio.UnixConnection.prototype.receive_credentials functions.

Since 2.26

Returns

null if @error is set, otherwise a Gio.Credentials object that must be freed with GObject.Object.prototype.unref.