Facebook Login Autorefreshes and loses token
matt-goldman opened this issue · 2 comments
Description
When using Facebook login, the window that opens sends the message back to the Facebook login component. Using a very quickly captured screenshot I can confirm that this contains the 'status' variable (showing true) and the access token. However, this page (Facebook login component) then immediately refreshes, resulting in the token being lost and the line const result = JSON.parse(message.data);
results in an undefined error.
Expected Behavior
The page should not refresh, the message should be parsed and the token sent to the facebookLogin function in the user service.
Current Behavior
Page refreshes and token is lost.
Steps to Reproduce
1.Build project as per tutorial
2. Verify code against Github repository
3. Run backend and client
4. Click Facebook Login on home screen, then the Login with Facebook button
5. Login to Facebook (if not already)
Basically turned out to be a typo in my code. Apologies for the unnecessary issue. Weirdly what compounded it for me was that I couldn't hit the breakpoint in my external auth controller (I would have expected the issue in question to result in a bad model state) but instead its as if the controller never got reached.
Sorry spoke to soon. The problem seems to be with this line:
var appAccessTokenResponse = await Client.GetStringAsync($"https://graph.facebook.com/oauth/access_token?client_id={_fbAuthSettings.AppId}&client_secret={_fbAuthSettings.AppSecret}&grant_type=client_credentials");
I've done some testing to ensure the url is getting translated correctly (which it is), but sending a get request to this url results in a 500 internal server error back from Facebook:
{
"error": {
"message": "An unknown error has occurred.",
"type": "OAuthException",
"code": 1,
"fbtrace_id": "xxxx"
}
}