diff options
author | George Hazan <ghazan@miranda.im> | 2019-06-19 17:35:12 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-06-19 17:35:12 +0300 |
commit | 855b21f95ed509e16892fa51cca9bdebe9044047 (patch) | |
tree | 839d005ddda31c37d79486ddca479784cfd3b410 /protocols/Facebook/src/server.cpp | |
parent | 062224cae32f5fbc5f47e5af74563b7389a4f7c0 (diff) |
request for retrieving token
Diffstat (limited to 'protocols/Facebook/src/server.cpp')
-rw-r--r-- | protocols/Facebook/src/server.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp index bcf2d2fdfe..dba8178fa8 100644 --- a/protocols/Facebook/src/server.cpp +++ b/protocols/Facebook/src/server.cpp @@ -29,17 +29,21 @@ void FacebookProto::OnLoggedOut() void FacebookProto::ServerThread(void *) { - auto *pReq = CreateRequest("authenticate", "auth.login"); - pReq->m_szUrl = FB_HOST_BAPI "/method/auth.login"; - pReq << CHAR_PARAM("email", getMStringA("Email")) << CHAR_PARAM("password", getMStringA("Password")); - pReq->CalcSig(); - - JsonReply reply(ExecuteRequest(pReq)); - if (reply.error()) { + m_szAuthToken = getMStringA(DBKEY_TOKEN); + if (m_szAuthToken.IsEmpty()) { + auto *pReq = new AsyncHttpRequest(); + pReq->requestType = REQUEST_GET; + pReq->flags = NLHRF_HTTP11 | NLHRF_REDIRECT; + pReq->m_szUrl = "https://www.facebook.com/v3.3/dialog/oauth?client_id=478386432928815&redirect_uri=https://oauth.miranda-ng.org/facebook.php&state=qq"; + + JsonReply reply(ExecuteRequest(pReq)); + if (reply.error()) { FAIL: - ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_FAILED, (HANDLE)m_iStatus, m_iDesiredStatus); + ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_FAILED, (HANDLE)m_iStatus, m_iDesiredStatus); - m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; - ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, m_iDesiredStatus); + m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; + ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, m_iDesiredStatus); + return; + } } } |