"detail": "Given token not valid for any token type" 토큰 인증 오류 해결

2025. 2. 19. 03:38·🕵️에러 해결사

에러 상황

Postman에서 사용자 정보 조회를 위해 인증 토큰을 Header로 Bearer token 전달을 하였으나, 다음과 같은 응답이 나옴

{
    "detail": "Given token not valid for any token type",
    "code": "token_not_valid",
    "messages": [
        {
            "token_class": "AccessToken",
            "token_type": "access",
            "message": "Token has no id"
        }
    ]
}

 

jwt.io 에서 토큰 정보에 user_id가 포함되어 있는 것도, 만료 기간이 한참 남은 것도 확인했으나,

여전히 token_not_valid가 나옴

 

이부분은 잘 정리된 에러 해결 방법이 없기에, 해결하기까지 무한 토큰 복사를 진행했다.. 

결국 GPT와 함께 해결!

 

에러 원인

아무래도 복붙했던 jwt 토큰의 문제가 있었던 것 같다.

위 응답을 보면 계속해서 token_type으로 "access"를 원하는데, 내가 붙여넣은 토큰은 액세스 토큰이 아니었던 것

따라서, access token을 확실하게 얻어내는 것이 중요하다

 

에러 해결

프로젝트의 urls.py에 다음을 추가하자.

from rest_framework_simplejwt.views import TokenObtainPairView

path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),

그리곤 Postman에 api/token 과 해당 사용자의 정보를 넘기면 

{
    "refresh": "ey~~",
    "access": "ey~~"
}

이런식으로 토큰이 뜨고, 밑줄 access의 토큰을 복붙해서 header에 넘기면 된다.

 

 

아흑 너무 힘들었어

'🕵️에러 해결사' 카테고리의 다른 글

Inferred type 'S' for type parameter 'S' is not within its bound; should implement 'org.apache.catalina.User' 에러 해결하기  (0) 2025.07.09
Windows에서 Python 파일 경로 오류 해결하기: 올바른 경로 입력 방법 총정리  (0) 2025.03.11
[Error]Id returned 1 exits status 에러 해결하기 (Dev C++)  (0) 2025.02.12
Spring Boot 프로젝트 실행 오류: Execution failed for task 해결 하기  (0) 2025.02.04
Spring Boot 프로젝트 실행 오류: Could not resolve all dependencies 해결하기  (0) 2025.02.04
'🕵️에러 해결사' 카테고리의 다른 글
  • Inferred type 'S' for type parameter 'S' is not within its bound; should implement 'org.apache.catalina.User' 에러 해결하기
  • Windows에서 Python 파일 경로 오류 해결하기: 올바른 경로 입력 방법 총정리
  • [Error]Id returned 1 exits status 에러 해결하기 (Dev C++)
  • Spring Boot 프로젝트 실행 오류: Execution failed for task 해결 하기
고딩코난
고딩코난
godingconan 님의 블로그 입니다.
  • 고딩코난
    코딩의 고난
    고딩코난
  • 전체
    오늘
    어제
    • 분류 전체보기 (16)
      • 🔰프레임워크 (0)
        • 🧩Spring (0)
        • 🥭Django (0)
      • 📓프로그래밍 언어 (0)
        • 🍵Java (0)
        • 🐍Python (0)
      • 🖥️CS (0)
        • 분산 시스템 (0)
      • 🔓알고리즘 (2)
        • 🌿백준 (2)
      • 🎞️프로젝트 (0)
      • 💸도전! 수익 창출 (0)
      • 🔖Lesson Learned (2)
      • 🕵️에러 해결사 (7)
      • 🌐Web (1)
      • 🔧Git&Github (2)
      • 🛡️Cloud (2)
        • 📡AWS (1)
        • NCP (1)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    프로토콜
    UDP
    프로젝트 생성
    종료 에러
    합격
    C++
    백준
    TCP
    1764
    정보처리기사 필기
    spring 프로젝트
    꿀팁
    버전 오류
    네트워크
    알고리즘
    IP
    Spring
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
고딩코난
"detail": "Given token not valid for any token type" 토큰 인증 오류 해결
상단으로

티스토리툴바