0

我已經將fb AccounKit與離子應用程序(NodeJS服務器)集成在一起。前端部分已經完成,我可以發送和接收OTP和成功狀態。當從nodeJS服務器交換令牌時,Facebook帳戶提供了錯誤

不過,雖然從授權碼獲取客戶端的令牌,我不斷收到「」錯誤驗證在\「的access_token \」令牌'」的錯誤。我跟着他們的官方文檔中提到的相同的過程。

這是我的代碼:?

var me_endpoint_base_url = 'https://graph.accountkit.com/v1.0/me'; 
token_exchange_base_url='https://graph.accountkit.com/v1.0/access_token'; 

var params = { 
    grant_type: 'authorization_code', 
    code: request.body.code, 
    access_token: app_access_token 
}; 
} 

// exchange tokens 
console.log(Querystring.stringify(params)) 
var token_exchange_url = token_exchange_base_url + '?' + Querystring.stringify(params); 
Request.get({url: token_exchange_url, json: true}, function(err, resp, respBody) { 
    console.log(respBody); 
    var view = { 
    user_access_token: respBody.access_token, 
    expires_at: respBody.expires_at, 
    user_id: respBody.id, 
    }; 
    var me_endpoint_url = me_endpoint_base_url + '?access_token=' + respBody.access_token; 
    Request.get({url: me_endpoint_url, json:true }, function(err, resp, respBody) { 
    console.log(respBody); 
    if (respBody.phone) { 
     view.method = "SMS" 
     view.identity = respBody.phone; 
    } else if (respBody.email) { 
     view.method = "Email" 
     view.identity = respBody.email.address; 
    } 
    }); 
}); 

請幫

回答

1

製作服務器到服務器的電話時,爲令牌交換代碼,您需要提供您的帳戶套件應用程序祕密的訪問令牌你發送。 所以訪問tok en應該看起來像:

'AA|{app_id}|{app_secret}' 

例如,

var app_access_token = ['AA', app_id, app_secret].join('|'); 

您可以從Account Kit儀表板找到您的應用程序祕密。在developers.facebook.com上的應用產品部分下的「Account Kit」頁面中,點擊「Account Kit App Secret」框旁邊的「Show」按鈕查看您的應用祕密。

還記得你應該從來沒有包括你的應用程序的祕密在客戶端上運行的任何JavaScript代碼。這個祕密只能用在你的服務器端node.js代碼中,其他人不應該看到它。

+0

謝謝。我使用的是AppSecret而不是Accountkit的AppSecret。現在它的工作。 –

+0

@AravindhNagarajan:請將此答案標記爲已接受的答案 – deksden

相關問題