Facebook chat - X-FACEBOOK-PLATFORM authentication

后端 未结 2 752
你的背包
你的背包 2021-01-25 21:40

I want to build an XMPP client on android, I\'ve got it running perfect with authentication using Digest-MD-5, however when I try to convert it to X-FACEBOOK-PLATFORM it keeps f

2条回答
  •  死守一世寂寞
    2021-01-25 22:33

    So basically the X-FACEBOOK-PLATFORM authentication uses only a part of a access token. That is called the session key.

    The access token is seperated by "|" characters, so you split the access token and only take the characters that are in the center. Refer below.

    ******|a681464febcefb8*-**|******

    long callId = new GregorianCalendar().getTimeInMillis() / 1000L;
    
                String sig = "api_key=" + apiKey
                                + "call_id=" + callId
                                + "method=" + method
                                + "nonce=" + nonce
                                + "session_key=" + sessionKey
                                + "v=" + version
                                + appSecret;
    
                try {
                    sig = MD5(sig);
                }
                catch (NoSuchAlgorithmException e) {
                    throw new IllegalStateException(e);
                }
    
                String composedResponse = "api_key=" + URLEncoder.encode(apiKey, "utf-8")
                                            + "&call_id=" + callId
                                            + "&method=" + URLEncoder.encode(method, "utf-8")
                                            + "&nonce=" + URLEncoder.encode(nonce, "utf-8")
                                            + "&session_key=" + URLEncoder.encode(sessionKey, "utf-8")
                                            + "&v=" + URLEncoder.encode(version, "utf-8")
                                            + "&sig=" + URLEncoder.encode(sig, "utf-8");
    

提交回复
热议问题