microsoft / cpprestsdk

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
7.96k stars 1.65k forks source link

Oauth1Client. How to detect browser close event ? #1658

Open thienphuoc opened 2 years ago

thienphuoc commented 2 years ago

Hi, I have tried many methods to detect browser close events. But, Unfortunately, I have not been able to detect the close.

image

I used this example here for google/facebook login: https://github.com/microsoft/cpprestsdk/blob/master/Release/samples/Oauth1Client/Oauth1Client.cpp

And I added this callback as below, but the result always returns "Completed" :

image

Could somebody give me some solution for this problem?

    _listener = new http_listener(url);
    _listener->support([this](http::http_request request) {

 //my code

        request.reply(web::http::status_codes::OK, json::value::string(U("Login success. Please close website!"))).then([this](pplx::task<void> result) {
         //my code
        });

    });

    _listener->open().then([this](pplx::task<void> result) {

      //my code
    }).wait();