문제 설명
모바일 클라이언트에서 서버 및 프로세스로 facebook 액세스 토큰 전달 (Pass facebook access token from mobile client to server and process)
모바일 클라이언트와 인터페이스하는 REST API 작업을 하고 싶습니다. 다음 흐름을 구현할 생각이며 여러분이 저를 올바른 방향으로 이끌 수 있기를 바랍니다.
- 사용자가 모바일 앱에 액세스한 다음 facebook(앱)에 가입합니다.
- 사용자가 자신을 성공적으로 인증하면 생성된 토큰이 API 엔드포인트를 통해 서버로 전달됩니다.
- 서버는 이 토큰을 수락하고 이 토큰을 사용하여 Facebook 서버에 쿼리하고 반환된 정보
이것이 가능합니까? 그리고 나는 올바른 방향으로 가고 있습니까?
참조 솔루션
방법 1:
Not only this is possible, but this is the approach which Facebook recommends. This is called "token debugging" in FB parlance.
The token will need to be checked and validated by your server, by calling the token debug Facebook api.
If you don't validate the token on the server, your app could be subject to various attacks, e.g. another developer could use a token generated on another app to gain entry.
The correct approach is:
- testing that the user is the one to whom the token belongs to
- that your app is the same for which the token was generated
- that the token itself is valid.
You can manually inspect a token, in order to test your code with an online tool: https://developers.facebook.com/tools/debug/
(by maximus 69、Michele Giuseppe Fadda)