xamarin 授权错误代码1000

r1wp621o  于 2022-12-07  发布在  其他
关注(0)|答案(8)|浏览(243)

我在DidCompleteWitherror中收到以下错误:

com.apple.AuthenticationServices.Authorization Error Code 1000

我正在使用以下代码登录Apple

var appleIdProvider = new ASAuthorizationAppleIdProvider();
var request = appleIdProvider.CreateRequest();
request.RequestedScopes = new ASAuthorizationScope[] { ASAuthorizationScope.Email, ASAuthorizationScope.FullName };
var authController = new ASAuthorizationController(new[] { request });
authController.Delegate = this;
authController.PresentationContextProvider = this;
authController.PerformRequests();
...
[Export("authorizationController:didCompleteWithAuthorization:")]
public void DidComplete(ASAuthorizationController controller, ASAuthorization authorization)
{
...
}

[Export("authorizationController:didCompleteWithError:")]
public void DidComplete(ASAuthorizationController controller, NSError error)
{
...
}
  • 我在授权列表中检查了Apple登录。plist
  • 我在管理控制台中创建了应用程序ID,验证了我的域。甚至Web身份验证已经工作了。
  • 我尝试将预置描述文件切换到使用Apple登录的描述文件。

此错误的原因可能是什么?

htrmnn0y

htrmnn0y1#

经过搜索,我发现它在一个真实的的设备上工作,有时不工作的模拟器.
但我通过登录here并删除Devices下的模拟器解决了这个问题。然后重新构建它。别忘了在“Signing & Capabilities”中添加“Sign in with Apple”。

bzzcjhmw

bzzcjhmw2#

我得到了这个错误,因为忘记添加登录功能和重新启动应用程序。

hvvq6cgz

hvvq6cgz3#

Fist of all, all above answer are correct to me.
Second, I spend some hours to found out that I miss add Sign with Apple ID Entitlements in release config, So I just past what I do here.
You can check by any one of bellow:

1. Check every tab under Signing & capabilities in Xcode

2. Search com.apple.developer.applesignin in vscode(or other file tool), you should find 3 Entitlements files

3. Check files in project folder in vscode(or other file tool), you should find 3 Entitlements files with com.apple.developer.applesignin included.

vmdwslir

vmdwslir4#

原来是csproj中缺少设置的问题。
在此找到答案:https://xamarin.github.io/bugzilla-archives/25/25141/bug.html
我打开csproj,发现一些构建配置缺少CodesignEntitlements,其中一些配置为空:

<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>

在所有构建配置中添加/更新它之后,它终于工作了。
PS:之前我试着创建一个空的xamarin项目(使用相同的包名),它在模拟器上重现了这个问题。然后我做了一个swift项目(使用相同的包名),它工作得很好。所以很明显,这是xamarin特有的bug。

omvjsjqw

omvjsjqw5#

A verification step from Apple is not required, despite the misleading documentation on their side.
Could you try to run a new build and make sure to create a new provisioning profile with updated capabilities inside?
Make sure the "Apple Sign-in" entitlement is added to your build settings, and in your Apple certs from the developer portal.
If you're running a development build, try switching to a production build. You might need to go as far as signing the app bundle for Ad Hoc distribution and installing it that way.
As you can check in the Apple Documentation , the 1000 error code really means that the error is unknown, so this solution may not work for you. In terms of your code, it seems alright to me! You can also check these samples !

w6lpcovy

w6lpcovy6#

我使用的是Swift,我想说的是,有时候iPhone上的Apple ID登录需要双因素授权,所以我的代码是

if #available(iOS 13.0, *) {
            let appleIDProvider = ASAuthorizationAppleIDProvider().createRequest()
            appleIDProvider.requestedScopes = [.fullName, .email]
            
            //let passwordProvider = ASAuthorizationPasswordProvider().createRequest()
            
            let authorizationController = ASAuthorizationController(authorizationRequests: [appleIDProvider])
            authorizationController.delegate = self
            authorizationController.presentationContextProvider = self
            authorizationController.performRequests()
        } else {
            // Fallback on earlier versions
        }

密码请求ASAuthorizationPasswordProvider被注解并跳过该行,原因是电话上的Apple ID。
当一个苹果ID需要进行双因素授权时,那么我们可以请求这个提供商ASAuthorizationPasswordProvider,我们要删除代码。删除代码行后,一切运行正常。

xpszyzbs

xpszyzbs7#

我通过将使用Apple登录添加到登录与功能点击中解决了此错误

xxe27gdn

xxe27gdn8#

我也有同样的问题。
我的代码:

if #available(iOS 13.0, *) {
    let appleIDProviderRequest = ASAuthorizationAppleIDProvider().createRequest()
    appleIDProviderRequest.requestedScopes = [.fullName, .email]
    let passwordProviderRequest = ASAuthorizationPasswordProvider().createRequest()
    let requests = [appleIDProviderRequest, passwordProviderRequest]

    // Create an authorization controller with the given requests.
    let authorizationController = ASAuthorizationController(authorizationRequests: requests)
    authorizationController.delegate = self
    authorizationController.presentationContextProvider = self
    authorizationController.performRequests()
}

我用两个苹果账户测试了这段代码。一个账户可以用,另一个不行。然后我删除了ASAuthorizationPasswordProvider().createRequest(),问题就消失了。我想苹果将来会解决这个问题的。

相关问题