kokbee-Hive
article thumbnail

언제나 깐깐한 애플에 요구사항중 하나였던, 애플 OAuth 로그인시 회원탈퇴시 revoke에 관한 내용이다.

https://developer.apple.com/kr/app-store/review/guidelines/#5.1.1

 

App Store 심사 지침 - Apple Developer

App Store 심사 지침에는 사용자 인터페이스 디자인, 기능, 콘텐츠 및 특정 기술 사용 등을 비롯하여 개발과 관련된 다양한 주제에 대한 지침과 예가 나와 있습니다. 이러한 지침은 앱 승인 절차를

developer.apple.com

 

 

 

 

왜 해야 하는가?

위와 같은 내용이 있고, 저 내용을 지켜달라는 권고가 내려왔다. 

정해진 기간에 안하면 "너희 앱 내려버릴거야!" 라고..

 

무조건 해야하는 상황, 따라서 내가 하게 되었다.

 

 

 

 

어떻게 해야 하는가?

심플하다. revoke API로 회원탈퇴시 애플측에 쏴주면 된다.

https://developer.apple.com/documentation/sign_in_with_apple/revoke_tokens

 

Revoke tokens | Apple Developer Documentation

Invalidate the tokens and associated user authorizations for a user when they are no longer associated with your app.

developer.apple.com

물론 서버는 API만 쏘면 되지만, 앱에서는 회원탈퇴시 애플로그인을 한번 더 해줘야하는게 추가되어야한다.

 

 

 

코드작성

step 1. revoke를 위한 공용 변수 선언

  const url = 'https://appleid.apple.com/auth/revoke'
  const client_id = myClinetId
  const client_secret = myClinetSecret

 

step 2. 앱에서 code를 전달받음

code = 'asdasdasdasdasdasd'

 

step 3. 앱에서 전달 받은 code로  auth token 발급

  const headers = { 'Content-Type': 'application/x-www-form-urlencoded' }
  const url = 'https://appleid.apple.com/auth/token'
  const form = {
    client_id,
    client_secret,
    code,
    grant_type: 'authorization_code',
  }

  return request({ method: 'POST' , url, headers, form })

 

step 4. revoke 진행

const authToken = code를 통해 받은 authToken
const headers = { 'Content-Type': 'application/x-www-form-urlencoded' }
const form = { client_id, client_secret, token: authToken['refresh_token'], token_type_hint: 'refresh_token' }

await request({ method: 'POST' , url, headers, form })

 

 

 

여담 - 삽질

  • code가 잘왔는데 revoke가 안된다.
    • 이유는 회사가 앱이 두개지만 같은 apns 파일을 이용하기에, id값들이 다른줄 알았던게 문제엿음 (앱팀 팀장님이 알려주심)
      • 코드가 문제인줄 👀

 

심사 통과 ✨

 

profile

kokbee-Hive

@콕비

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!