はじめに
fastlane spaceauth -u {Apple ID}
を実行して FASTLANE_SESSION
環境変数を生成しようとしたら、6桁の確認コードの入力後に Spaceship::UnauthorizedAccessError
エラーが発生しました。
(検索用に全文載せていますが、エラーは「Please enter the 6 digit code:」からです)
$ bundle exec fastlane spaceauth -u {Apple ID}
[✔] 🚀
Logging into to App Store Connect ({Apple ID})...
Available session is not valid any more. Continuing with normal login.
Two-factor Authentication (6 digits code) is enabled for account '{Apple ID}'
More information about Two-factor Authentication: https://support.apple.com/en-us/HT204915
If you're running this in a non-interactive session (e.g. server or CI)
check out https://github.com/fastlane/fastlane/tree/master/spaceship#2-step-verification
(Input `sms` to escape this prompt and select a trusted phone number to send the code as a text message)
(You can also set the environment variable `SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER` to automate this)
(Read more at: https://github.com/fastlane/fastlane/blob/master/spaceship/docs/Authentication.md#auto-select-sms-via-spaceship-2fa-sms-default-phone-number)
Please enter the 6 digit code:
XXXXXX
Requesting session...
Could not login to App Store Connect
Please check your credentials and try again.
This could be an issue with App Store Connect,
Please try unsetting the FASTLANE_SESSION environment variable
(if it is set) and re-run `fastlane spaceauth`
Exception type: Spaceship::UnauthorizedAccessError
Looking for related GitHub issues on fastlane/fastlane...
➡️ fastlane cert got Unauthorized Access error
https://github.com/fastlane/fastlane/issues/16108 [open] 31 💬
an hour ago
➡️ The request could not be completed because: Unauthorized Access
https://github.com/fastlane/fastlane/issues/15411 [closed] 22 💬
08 Jan 2020
➡️ Unauthorized Access when I use Fastlane pilot upload
https://github.com/fastlane/fastlane/issues/15125 [closed] 6 💬
13 Nov 2019
and 16 more at: https://github.com/fastlane/fastlane/search?q=The%20request%20could%20not%20be%20completed%20because%3A%0A%09Unauthorized%20Access&type=Issues&utf8=✓
🔗 You can ⌘ + double-click on links to open them directly in your browser.
[!] The request could not be completed because:
Unauthorized Access
解決に苦戦したので、備忘録として残します。
結論
SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER
環境変数に2FA用の携帯電話番号を設定したあと、 fastlane spaceauth -u {Apple ID}
を実行します。
# 例:電話番号が「080-XXXX-XXXX」の場合
$ export SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER=+81-80-XXXX-XXXX
$ fastlane spaceauth -u {Apple ID}
Bundlerで管理している場合、先頭に bundle exec
を付けるのを忘れないでください。
環境
- Fastlane:2.143.0
解決理由
わかりません…w
手動で6桁の確認コードを入力する場合より、いろいろなことをやっているのかもしれません。
ちなみにですが、 fastlane init
で同様のエラーが発生した場合も、本記事の方法で解決しました。