최근에 OAuth를 이용한 로그인 시스템을 구현하면서 login client를 NuGet Package로 만들었었다. 다른 개발자들이 쉽게 로그인 기능을 이용할 수 있도록. 그런데 자꾸만 acquired token을 저장하는 static Dicionary에서 Null Reference error가 나는게 아닌가. Dictionary.Insert에서…
Dictionary.Get에서 나면 몰라도 Insert에서 Null error가 나서 쫌 구글해보니, StackOverflow의 어느 고수께서 이미 답변. Threading 이슈라고.
그 아래 다른분은 ConcurrentDictionary를 쓰라고 친절하고 부연 설명까지.
The official document (https://developers.facebook.com/docs/facebook-login/login-flow-for-web) is the best tutorial. But when you follow it, there’s a few things you have to take notice.
First, you need to get your app id, if you don’t have it. You can create an app by visiting app dashboard (https://developers.facebook.com/apps/). Fill all the details but make sure you set it to “Website” by clicking “+ Add Platform”
Then, you will try your test code. Unfortunately, it will be likely to fail, as you didn’t set “App Domains” for your website. If you are smart enough to set it at the first time, then no problem.
The error message is like the above. So, you have to set app domains. You can set your production domain like “yourdomain.com” but you would also need to test it on your local dev machine. For me, I use host file (C:\Windows\System32\drivers\etc\hosts)
And add the test domain to your app settings in the app dashboard.
Then it’s done. It should log you successfully. If it doesn’t, please let me know.
Security matters, and you need to authenticate your api calls.
There are a few ways to do it. You can insert authentication cookie into the http header of your api call. Or you can use OAuth. There is a short-lived OAuthWrap, which gave in to OAuth2.
to be continued …