mas-cli/mas

`signin` disabled on macOS 10.13+

phatblat opened this issue Β· 62 comments

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

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?

Can we open the App Store GUI on 10.13+?

@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.

@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.

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

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

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.

Workaround described does not work in Mojave...

@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.

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

@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).

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

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 ;)

any news for 1.4.3?

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

very awesome, seems to work for me. thanks

@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?

screenshot 2018-10-29 22 07 13

Still disabled.

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

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

see #164 (comment)

Not sure why, but even running

  • mas signout
  • Sign in using App Store.app
  • mas search Xcode

returns empty results

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.

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

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 yes, this project uses class-dump as well to generate headers for the private frameworks. See ISAccountService.h

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.

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... :(

Ha.
sudo jamf removeMDMProfile removes all restrictions

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

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

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

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

@phatblat Any sign of solutions to this?

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 ;)

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πŸ€¦πŸ»β€β™‚οΈπŸ˜…

@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 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.

🀞🏼

@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.

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

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

@pointlessone use mas account to check login status

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

on Monterey beta neither login in Mac app store gui works

Using

  • mas 1.8.3
  • 12.0 Beta (21A5534d) (beta 8)

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

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

Any news on this?

Any update on this??

need a fix for this issue.

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.

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

Mthld commented

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

Same on MacBook Air M1 12.0.1 (21A559).

Still the same on 2019 Intel MacBook macOS 12.0.1 (21A559); not logged in state reported by mas although the App Store GUI shows me logged in.

After my upgrade to 12.0.1 it all broke again. Sigh.

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

2016 MBP here, GUI sign in workaround failing after update to 12.01 (21A559)

Unable to sign in with mas signin and also mas doesn't recognize signing in through App Store app.

mid-2017 MBP
macOS Monterey 12.0.1
mas 1.8.3

For those reporting failures on macOS Monterey, you may be interested in #417 instead of this issue, which dates back to High Sierra.

For those reporting failures on macOS Monterey, you may be interested in #417 instead of this issue, which dates back to High Sierra.

Thanks!

Any update on this??

So, is there anyone who can tell me how to avoid this error 😭

The 'signin' command has been disabled on this macOS version. Please sign into the Mac App Store app manually.


macOS Monterey 12.0.1
mbp 19

With lastest mas update works on Monterey

it workedπŸ‘
MBP 2021 14inch M1 Pro
macOS Monterey 12.2.1
mas 1.8.6

doesn't work for me on ventura 13.2
MBP Pro 2023 M2
mas 1.8.6