Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spaceship] Fix Apple ID 2FA with SMS #21072

Merged
merged 1 commit into from Feb 23, 2023
Merged

Conversation

joshdholtz
Copy link
Member

@joshdholtz joshdholtz commented Feb 23, 2023

Motivation and Context

Fixes #21071

Description

More info coming soon

Testing Steps

Update Gemfile and run bundle install, bundle update fastlane, or bundle update

gem "fastlane", :git => "https://github.com/fastlane/fastlane.git", :branch => "joshdholtz-fix-apple-id-2fa"

@@ -61,9 +61,17 @@ def handle_two_step_for_device(device_id)

# Send token to server to get a valid session
r = request(:post) do |req|
req.url("https://idmsa.apple.com/appleauth/auth/verify/device/#{device_id}/securitycode")
req.url("https://idmsa.apple.com/appleauth/auth/verify/phone/securitycode")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So i think the original url was correct, but your body was wrong.

In Xcodes - https://github.com/RobotsAndPencils/XcodesApp/blob/main/Xcodes/AppleAPI/Sources/AppleAPI/URLRequest%2BApple.swift#L68

Depending on if it's sms or device it'll send different bodies.

for SMS: verify/phone/securitycode

  req.body = {
          "phoneNumber": {
            "id": device_id
          },
          "securityCode": {
            "code" => code.to_s
          },
          "mode": "sms"

for trusted device: ``verify/trusteddevice/securitycode`

  req.body = {
          "securityCode": {
            "code" => code.to_s
          }

That hasn't changed for a while and has been working, but maybe that has changed now 🤷

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah yeah, the body definitely seemed wrong so not really sure how it didn't break sooner 🤷‍♂️

But... the new url/updated URL look correct though too, right? This is what proxyman showed me today 👇

Screenshot 2023-02-23 at 12 21 28 PM

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is not many people use sms as their 2fa vs a trusted device

that Updated url looks correct for SMS 2FA. For trusted device it's:

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah yeah, we have a separate path for trusted devices that uses that URL and body already 😊

👉 https://github.com/fastlane/fastlane/blob/master/spaceship/lib/spaceship/two_step_or_factor_client.rb#L162-L170

@joshdholtz
Copy link
Member Author

Punting on the fix for trusted devices because it seems like that might be an issue on Apple and its not reproducible anymore for me 😔

@joshdholtz joshdholtz merged commit af2f3e6 into master Feb 23, 2023
@joshdholtz joshdholtz changed the title [spaceship] Fix Apple ID 2FA from locking Apple accounts [spaceship] Fix Apple ID 2FA with SMS Feb 23, 2023
@aquacode
Copy link

If I update fastlane using gem "fastlane", :git => "https://github.com/fastlane/fastlane.git", :branch => "joshdholtz-fix-apple-id-2fa" is spaceauth cli to generate session supposed to work now because I get the same errors.

@andrewheavin
Copy link

@joshdholtz - You'll love this, its now magically working again and I'm running 2.210.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't ask verification code and access forbiden and apple account block
4 participants