Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

Facebook - ASP.NET/WebClient 사용 시 graph.facebook.com/me 호출에 대해 403 Forbidden 오류

잘 동작하던 Facebook의 Graph API 호출이,

string url = "https://graph.facebook.com/me?fields=email&access_token=" + access_token;
wc = new WebClient();
string text = wc.DownloadString(url); // 예외 발생

어느 순간부터 403 오류가 발생합니다.

System.Net.WebException
  HResult=0x80131509
  Message=The remote server returned an error: (403) Forbidden.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

Facebook 개발자 페이지에 들어가 해당 App에 대해 설정을 찾아봐도 별다른 특이점이 없습니다. 그러다, 혹시나 싶어 nuget으로부터 Facebook 패키지를 참조해,

Install-Package Facebook

// Install-Package Facebook -Version 7.0.6

제공하는 코드를 사용했더니,

var client = new FacebookClient(access_token);
dynamic me = client.Get("me");

이런 오류로 바뀝니다.

Facebook.FacebookApiException
  HResult=0x80131500
  Message=(GraphInsecureException - #8) TLS versions older than v1.2 are not supported.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

그러니까, 결국 예전에 설명한 문제가 Facebook의 API 서버 호출에도 발생한 것으로,

C# - WebClient로 https 호출 시 "The request was aborted: Could not create SSL/TLS secure channel" 예외 발생
; https://www.sysnet.pe.kr/2/0/13233

JetBrains Omea Reader에서 TLS 1.2 모드의 https 서버로부터 RSS 구독이 안 되는 경우 해결 방법
; https://www.sysnet.pe.kr/0/0/547

Facebook 측에서 낮은 버전의 TLS 지원을 더 이상 하지 않기로 결정한 것입니다. 따라서 해결책은 Global 타입의 정적 생성자에 Tls12 옵션을 추가해 주면 됩니다. ^^

public class Global : System.Web.HttpApplication
{
    static Global()
    {
        ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
    }

    // ...[생략]...
}

그나저나... 이런 변화들은 다소 심각한 문제로 보입니다. 가령, (이미 외주 개발이 끝난) 예전 ASP.NET으로 만들어진 사이트들의 경우 어느 순간부터는 로그인 오류가 발생해 버리기 때문입니다.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 5/31/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... [16]  17  18  19  20  21  22  23  24  25  26  27  28  29  30  ...
NoWriterDateCnt.TitleFile(s)
13090정성태6/29/20224170오류 유형: 815. PyPI에 업로드한 패키지가 반영이 안 되는 경우
13089정성태6/28/20224564개발 환경 구성: 646. HOSTS 파일 변경 시 Edge 브라우저에 반영하는 방법
13088정성태6/27/20223637개발 환경 구성: 645. "Developer Command Prompt for VS 2022" 명령행 환경의 폰트를 바꾸는 방법
13087정성태6/23/20226175스크립트: 41. 파이썬 - FastAPI / uvicorn 호스팅 환경에서 asyncio 사용하는 방법 [1]
13086정성태6/22/20225772.NET Framework: 2026. C# 11 - 문자열 보간 개선 2가지파일 다운로드1
13085정성태6/22/20225863.NET Framework: 2025. C# 11 - 원시 문자열 리터럴(raw string literals)파일 다운로드1
13084정성태6/21/20224491개발 환경 구성: 644. Windows - 파이썬 2.7을 msi 설치 없이 구성하는 방법
13083정성태6/20/20224840.NET Framework: 2024. .NET 7에 도입된 GC의 메모리 해제에 대한 segment와 region의 차이점 [1]
13082정성태6/19/20224185.NET Framework: 2023. C# - Process의 I/O 사용량을 보여주는 GetProcessIoCounters Win32 API파일 다운로드1
13081정성태6/17/20224377.NET Framework: 2022. C# - .NET 7 Preview 5 신규 기능 - System.IO.Stream ReadExactly / ReadAtLeast파일 다운로드1
13080정성태6/17/20224934개발 환경 구성: 643. Visual Studio 2022 17.2 버전에서 C# 11 또는 .NET 7.0 preview 적용
13079정성태6/17/20222939오류 유형: 814. 파이썬 - Error: The file/path provided (...) does not appear to exist
13078정성태6/16/20224798.NET Framework: 2021. WPF - UI Thread와 Render Thread파일 다운로드1
13077정성태6/15/20225260스크립트: 40. 파이썬 - PostgreSQL 환경 구성
13075정성태6/15/20224287Linux: 50. Linux - apt와 apt-get의 차이 [2]
13074정성태6/13/20224464.NET Framework: 2020. C# - NTFS 파일에 사용자 정의 속성값 추가하는 방법파일 다운로드1
13073정성태6/12/20224812Windows: 207. Windows Server 2022에 도입된 WSL 2
13072정성태6/10/20224736Linux: 49. Linux - ls 명령어로 출력되는 디렉터리 색상 변경 방법
13071정성태6/9/20225349스크립트: 39. Python에서 cx_Oracle 환경 구성
13070정성태6/8/20224972오류 유형: 813. Windows 11에서 입력 포커스가 바뀌는 문제 [1]
13069정성태5/26/20226809.NET Framework: 2019. C# - .NET에서 제공하는 3가지 Timer 비교 [2]
13068정성태5/24/20225818.NET Framework: 2018. C# - 일정 크기를 할당하는 동안 GC를 (가능한) 멈추는 방법 [1]파일 다운로드1
13067정성태5/23/20225189Windows: 206. Outlook - 1년 이상 지난 메일이 기본적으로 안 보이는 문제
13066정성태5/23/20224704Windows: 205. Windows 11 - Windows + S(또는 Q)로 뜨는 작업 표시줄의 검색 바가 동작하지 않는 경우
13065정성태5/20/20225190.NET Framework: 2017. C# - Windows I/O Ring 소개 [2]파일 다운로드1
13064정성태5/18/20224916.NET Framework: 2016. C# - JIT 컴파일러의 인라인 메서드 처리 유무
... [16]  17  18  19  20  21  22  23  24  25  26  27  28  29  30  ...