mas-cli / mas

:package: Mac App Store command line interface
MIT License
10.73k stars 270 forks source link

🚏πŸ“₯πŸ™…β€β™€οΈ Signin command disabled on macOS 10.13+ #164

Open phatblat opened 5 years ago

phatblat commented 5 years ago

As of version 1.4.2 the signin command has been disabled on newer versions of macOS. This is an interim workaround to the crasher first identified in #107.

mas 1.4.2 was never released through Homebrew, so it must besownloaded and installed manually from the 1.4.2 release or built from source using Xcode.

😞 Situation

In macOS High Sierra (10.13) Apple removed the -[ISAccountService signInWithContext:replyBlock:] method from the StoreFoundation private Apple framework which this app relies on to authenticate users through the signin command. I have done a lot of digging and debugging but have not found another API that works to authenticate a user with the Mac App Store.

Users running older macOS versions (10.9-10.12) are unaffected.

πŸ‘‰πŸ»βŒ¨οΈ Workaround

Sign into the Mac App Store GUI app manually. Once signed in MAS app, the mas command should work fine.

I know this is not an ideal scenario, especially for script automation. Hopefully, I'll find a real solution to this soon.

Please πŸ‘ this issue if you are affected by it.

Related: #107, #129, #147, #155, #159, #160, #162

b3cramer commented 5 years ago

This impacts me quite a bit as I rely on mas to automate updates on my Mac labs. I'm happy to help look for solutions as I am able. Does anyone have a list of Apple API resources as a start?

SConaway commented 5 years ago

Can we open the App Store GUI on 10.13+?

phatblat commented 5 years ago

@SConaway the --dialog option to the signin command wasn't effective to open the MAS GUI because it would crash before causing the app to launch.

phatblat commented 5 years ago

@b3cramer docs for all of Apple's public frameworks is available online, but no docs or developer support is available for private frameworks. If you are interested in perusing these private frameworks, you can use the aging class-dump command to generate headers from the binaries on your mac. I've done this for some versions of macOS in my macOSPrivateFrameworks repo.

SConaway commented 5 years ago

I'll prolly do that tomorrow of 10.14. I'll make a PR to you with them.

jpartain89 commented 5 years ago

Well, the signin command isn’t disabled on Mojave and it’s still crashing the same for me.

robfletcher commented 5 years ago

With Mojave mas seems to just no-op on commands like outdated or upgrade (I can see pending updates in the App Store but mas doesn't report them). The account command reports that I am not signed in (I have signed in to App Store), the signin command produces a large error stack.

franklouwers commented 5 years ago

Workaround described does not work in Mojave...

phatblat commented 5 years ago

@jpartain89 @robfletcher @franklouwers What version of mas were you using? Note that this change was introduced in 1.4.2 which has not been released through Homebrew.

shpoont commented 5 years ago

I just tried 1.4.2 and it works.

$ ./mas-1.4.1 signin example@example.com
==> Signing in to Apple ID: example@example.com
Password:
2018-10-02 13:43:20.542 mas-1.4.1[87389:4605362] -[__NSXPCInterfaceProxy_ISAccountService signInWithContext:replyBlock:]: unrecognized selector sent to instance 0x7f849640d210
2018-10-02 13:43:20.543 mas-1.4.1[87389:4605362] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSXPCInterfaceProxy_ISAccountService signInWithContext:replyBlock:]: unrecognized selector sent to instance 0x7f849640d210'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff3bb1d43d __exceptionPreprocess + 256
    1   libobjc.A.dylib                     0x00007fff67a2e720 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff3bb9a255 -[NSObject(NSObject) __retain_OA] + 0
    3   CoreFoundation                      0x00007fff3babcad0 ___forwarding___ + 1486
    4   CoreFoundation                      0x00007fff3babc478 _CF_forwarding_prep_0 + 120
    5   mas-1.4.1                           0x000000010d76d452 mas-1.4.1 + 201810
    6   mas-1.4.1                           0x000000010d78ab70 mas-1.4.1 + 322416
    7   mas-1.4.1                           0x000000010d7561e4 mas-1.4.1 + 106980
    8   mas-1.4.1                           0x000000010d7426fd mas-1.4.1 + 26365
    9   mas-1.4.1                           0x000000010d742590 mas-1.4.1 + 26000
    10  mas-1.4.1                           0x000000010d754276 mas-1.4.1 + 98934
    11  mas-1.4.1                           0x000000010d73f7ef mas-1.4.1 + 14319
    12  libdyld.dylib                       0x00007fff68afc085 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6
$ ./mas-1.4.2 signin example@example.com
Error: The 'signin' command has been disabled on this macOS version. Please sign into the Mac App Store app manually.
For more info see: https://github.com/mas-cli/mas/issues/164

There is another problem with 1.4.1 (don't think it was mentioned before) which makes 1.4.1 completely broken on Mojave

$ ./mas-1.4.1 account
Not signed in
Error: Not signed in
./mas-1.4.2 account
example@example.com
robfletcher commented 5 years ago

@phatblat I'm using 1.4.1 from Homebrew

Is 1.4.2 coming to homebrew or is there a reason it's being held back? Happy to install it another way if so. I use mas mainly via https://github.com/DanielThomas/oh-your-dotfiles (I added the mas support to that).

ThomasKoppensteiner commented 5 years ago

@robfletcher the PR for mas version 1.4.2 was declined. See #174.

tiiiecherle commented 5 years ago

Hey, first of all thanks for this project, I really like it.

Regarding the not working install via mas on the command line I came up with a workaround until another solution can be found.

I maintain a github project which aims at automating install, customization and updates of macos. You can find it here: https://github.com/tiiiecherle/osx_install_config

As part of homebrew install scrips I added a bash script that installs mas, opens the appstore via applescript and enters apple-id and password before closing the appstore to automate the complete process. The script prompts you for your credentials to use it later in the appstore. If you want to autmate it completely just export your credentials before running the script. The script can be found here.

https://github.com/tiiiecherle/osx_install_config/blob/master/05_homebrew_and_casks/5b_homebrew_cask/6_mas_appstore.sh

Link Update due to project restructuring... https://github.com/tiiiecherle/osx_install_config/blob/master/03_homebrew_casks_and_mas/3b_homebrew_casks_and_mas_install/6_mas_appstore.sh

Be sure to download the complete folder 05_homebrew_and_casks and run the script from there without deleting the other scripts as it uses other scripts in the directory to check and define variables and components of the script to avoid redundant code in the other scripts in the same directory.

Hope it helps anyone ;)

hypery2k commented 5 years ago

any news for 1.4.3?

phatblat commented 5 years ago

@hypery2k Yes! It’s out now on Homebrew. Just landed today

hypery2k commented 5 years ago

very awesome, seems to work for me. thanks

tiiiecherle commented 5 years ago

@phatblat Thanks for the update ;)

@hypery2k What do you mean by working for you? Signin is still disabled on the command line, isn`t it?

jem-swu commented 5 years ago

screenshot 2018-10-29 22 07 13

Still disabled.

phatblat commented 5 years ago

@jem-swu yep. Signin will stay disabled to avoid the crash until there is a fix for this issue

tiiiecherle commented 5 years ago

@phatblat ok, thanks for the heads-up. I updated the automatic login by applescript around two weeks ago. Worked fine while testing...

see https://github.com/mas-cli/mas/issues/164#issuecomment-427061409

qkdreyer commented 5 years ago

Not sure why, but even running

returns empty results

CourierKyn commented 5 years ago

mas install seems to work well now, while mas search and mas lucky didn’t work yet.

在 2018εΉ΄10月30ζ—₯οΌŒδΈ‹εˆ5:05,Quentin Dreyer notifications@github.com ε†™ι“οΌš

Not sure why, but even running

mas signout Sign in using App Store.app mas search Xcode returns empty results

β€” You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

bigdaddybesbris commented 5 years ago

Hey, first of all thanks for this project, I really like it.

Regarding the not working install via mas on the command line I came up with a workaround until another solution can be found.

I maintain a github project which aims at automating install, customization and updates of macos. You can find it here: https://github.com/tiiiecherle/osx_install_config

As part of homebrew install scrips I added a bash script that installs mas, opens the appstore via applescript and enters apple-id and password before closing the appstore to automate the complete process. The script prompts you for your credentials to use it later in the appstore. If you want to autmate it completely just export your credentials before running the script. The script can be found here.

https://github.com/tiiiecherle/osx_install_config/blob/master/05_homebrew_and_casks/5b_homebrew_cask/6_mas_appstore.sh

Be sure to download the complete folder 05_homebrew_and_casks and run the script from there without deleting the other scripts as it uses other scripts in the directory to check and define variables and components of the script to avoid redundant code in the other scripts in the same directory.

Hope it helps anyone ;)

How do I integrate the automated App Store login into an already existing script? I'm working on scripting deployments to help make my job a little easier. A specific department requires Xcode and other plugins via brew, so I wrote a basic script to install the plugins and (hopefully) Xcode.

tiiiecherle commented 5 years ago

Hey, first of all thanks for this project, I really like it. Regarding the not working install via mas on the command line I came up with a workaround until another solution can be found. I maintain a github project which aims at automating install, customization and updates of macos. You can find it here: https://github.com/tiiiecherle/osx_install_config As part of homebrew install scrips I added a bash script that installs mas, opens the appstore via applescript and enters apple-id and password before closing the appstore to automate the complete process. The script prompts you for your credentials to use it later in the appstore. If you want to autmate it completely just export your credentials before running the script. The script can be found here. https://github.com/tiiiecherle/osx_install_config/blob/master/05_homebrew_and_casks/5b_homebrew_cask/6_mas_appstore.sh Be sure to download the complete folder 05_homebrew_and_casks and run the script from there without deleting the other scripts as it uses other scripts in the directory to check and define variables and components of the script to avoid redundant code in the other scripts in the same directory. Hope it helps anyone ;)

How do I integrate the automated App Store login into an already existing script? I'm working on scripting deployments to help make my job a little easier. A specific department requires Xcode and other plugins via brew, so I wrote a basic script to install the plugins and (hopefully) Xcode.

Just copy the respective variables, functions and parts of https://github.com/tiiiecherle/osx_install_config/blob/master/05_homebrew_and_casks/5b_homebrew_cask/6_mas_appstore.sh to your script and it should work.

Link Update due to project restructuring... https://github.com/tiiiecherle/osx_install_config/blob/master/03_homebrew_casks_and_mas/3b_homebrew_casks_and_mas_install/6_mas_appstore.sh

tiiiecherle commented 5 years ago

For anyone looking for the login workaround in my script. I restructured my project. In the process the script folder was renamed and the script moved to a new location:

https://github.com/tiiiecherle/osx_install_config/blob/master/03_homebrew_casks_and_mas/3b_homebrew_casks_and_mas_install/6_mas_appstore.sh

Jarli01 commented 4 years ago

Has anyone looked at this? https://github.com/w0lfschild/macOS_headers/blob/master/macOS/PrivateFrameworks/StoreFoundation/8/ISAccountService-Protocol.h

phatblat commented 4 years ago

@Jarli01 yes, this project uses class-dump as well to generate headers for the private frameworks. See ISAccountService.h

andysousa commented 4 years ago

has anyone found a way to do a signin without being able to actually launch the appstore? Its blocked by JamF... mas was working great for me, but i got signed out due to a password change. Now I can't sign back in because my company has decided to block access to the app store.

YannBrrd commented 4 years ago

has anyone found a way to do a signin without being able to actually launch the appstore? Its blocked by JamF... mas was working great for me, but i got signed out due to a password change. Now I can't sign back in because my company has decided to block access to the app store.

+1 here. If you have an option... :(

StevenACoffman commented 4 years ago

Ha. sudo jamf removeMDMProfile removes all restrictions

sudo jamf manage brings back all restrictions and profiles More here and much more here

andysousa commented 4 years ago

Ha. sudo jamf removeMDMProfile removes all restrictions

sudo jamf manage brings back all restrictions and profiles More here and much more here

HOLY CRAP! You are a genius ;-) . THANK YOU

trapacska commented 4 years ago

Hey!

What about /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/PrivateFrameworks/AuthKit.framework?

AuthKit has - (void)authenticateWithContext:(id)arg1 completion:(id /* block */)arg2; in it. Maybe they moved that in this framework?

For iOS here is a dump: https://github.com/JaviSoto/iOS10-Runtime-Headers/blob/master/PrivateFrameworks/AuthKit.framework/AKAppleIDAuthenticationController.h

ykhandelwal913 commented 4 years ago

I am facing the same issue of signin being disabled. Apart from login via appstore manually, is there any other workaround i can use?

danielbayley commented 4 years ago

@phatblat Any sign of solutions to this?

tiiiecherle commented 4 years ago

I am facing the same issue of signin being disabled. Apart from login via appstore manually, is there any other workaround i can use?

see my comment above ;)

danielbayley commented 4 years ago

see my comment above ;)

@tiiiecherle Thanks, yeah I did adapt the AppleScript and got it working along with tccutil… but unfortunately hit another road block in that a script can't deal with 2FAπŸ€¦πŸ»β€β™‚οΈπŸ˜…

tiiiecherle commented 4 years ago

@danielbayley I'm sorry I cannot help out with that as the script really can't deal with two factor authentication. I hope there will be a straight forward command line login possibility any time soon.

danielbayley commented 4 years ago

@danielbayley I'm sorry I cannot help out with that as the script really can't deal with two factor authentication. I hope there will be a straight forward command line login possibility any time soon.

🀞🏼

straxhaber commented 4 years ago

@phatblat Have you considered integrating @tiiiecherle's apple script into mas? If you're worried about the security and purity aspects of mixing GUI code into a command-line utility, perhaps you could make it an option that requires explicit action (for example, a --use-applescript flag). While this isn't ideal, it would be better than nothing for some use cases.

tiiiecherle commented 3 years ago

For anyone interested in trying the updated version of the login script. It should be compatible with macOS Big Sur now ;)

I'm looking forward to any feedback.

https://github.com/tiiiecherle/osx_install_config/blob/master/03_homebrew_casks_and_mas/3b_homebrew_casks_and_mas_install/6_mas_appstore.sh

pointlessone commented 3 years ago

Is there a way to check whether the user is currently signed in?

phatblat commented 3 years ago

@pointlessone use mas account to check login status

tekumara commented 3 years ago

My current workaround, which requires user action, so not suitable for a non-interactive script:

# sign in to App Store
if ! mas account >/dev/null; then
    echo "Please open App Store and sign in using your Apple ID ...."
    until mas account >/dev/null; do
        sleep 5
    done
fi
cmalvi commented 2 years ago

on Monterey beta neither login in Mac app store gui works

oschrenk commented 2 years ago

Using

I always get

$ mas account
Not signed in
Error: Not signed in

$ mas signin john.doe@email.com
Error: The 'signin' command has been disabled on this macOS version. Please sign into the Mac App Store app manually.
For more info see: https://github.com/mas-cli/mas/issues/164

The App Store UI does report me as being logged in. I also tried signing out, and signing back in. It did not change the results

kylerjensen commented 2 years ago

Same here; mas will not work with macOS Monterey until this is fixed.

fpesch commented 2 years ago

Any news on this?

ghost commented 2 years ago

Any update on this??

need a fix for this issue.

stephenulmer commented 2 years ago

FWIW, on macOS 12.0 (arm64) after signing into the App Store with the GUI, I was able to use mas upgrade to upgrade the installed apps. I was also able to use mas install to add working apps. So I think we're just in the place we've been for years -- able to do everything but sign in.

davidrothera commented 2 years ago

Things worked fine on 12.0 (32A344) which shipped on my M1 Max but once updated to 12.0.1 (21A559) is the same "not logged in" state