언제나 깐깐한 애플에 요구사항중 하나였던, 애플 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값들이 다른줄 알았던게 문제엿음 (앱팀 팀장님이 알려주심)
- 코드가 문제인줄 👀
- 이유는 회사가 앱이 두개지만 같은 apns 파일을 이용하기에, id값들이 다른줄 알았던게 문제엿음 (앱팀 팀장님이 알려주심)
심사 통과 ✨
'개발노트 > 개발기록' 카테고리의 다른 글
알리페이 결제연동 토큰 발급 및 연동하기 (0) | 2023.06.22 |
---|---|
데이터독 적용 및 세팅 (0) | 2023.06.05 |
iOS Storekit2 사용 및 결제 개선 (0) | 2023.06.01 |
[App Push] 앱 푸시 고도화 part.3 (Pushy - CN) (0) | 2023.04.19 |
[App Push] 앱 푸시 고도화 part.2 (FCM) (0) | 2023.03.13 |