> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portalhq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# loginWithApple

> Get an Apple sign-in URL for the app to open in a browser.

## Function Signature

```dart theme={null}
Future<PortalAuthorizeUrl> loginWithApple()
```

## Description

A [`PortalAuth`](./portalauth) method. Returns the Apple sign-in URL for the configured auth environment. It is opened and completed the same way as [`loginWithGoogle`](./portalauthloginwithgoogle): your app opens `authorizeUrl` in a browser, and passes the redirect to [`handleRedirect`](./portalauthhandleredirect).

Every call fetches a new single-use URL, so open it right away and never cache it.

Portal identifies end users by email. A user who picks Apple's *Hide My Email* signs in with a relay address, so they become a different end user, with a different wallet, from the same person signing in with Google or a magic link.

Available starting from `portal_flutter` 2.0.0.

## Parameters

This method takes no parameters.

## Returns

**`PortalAuthorizeUrl`** - An object containing:

| Property | Type | Description |
| - | - | - |
| `authorizeUrl` | `String` | The URL to open in a browser. |

## Example

```dart theme={null}
import 'package:portal_flutter/portal_flutter.dart';
import 'package:url_launcher/url_launcher.dart';

final result = await PortalAuth().loginWithApple();

await launchUrl(
  Uri.parse(result.authorizeUrl),
  mode: LaunchMode.externalApplication,
);
```

## Errors

| Code | Description |
| - | - |
| `AUTH_NOT_CONFIGURED` | Called before [`configure`](./portalauthconfigure) |
| `AUTH_METHOD_UNAVAILABLE` | Apple is not enabled for the environment. Not retryable |
| `AUTH_ACCOUNT_ABSTRACTION_UNAVAILABLE` | `isAccountAbstracted: true` was requested without gas sponsorship enabled. iOS only; Android reports `AUTH_LOGIN_WITH_APPLE_ERROR` |
| `AUTH_LOGIN_WITH_APPLE_ERROR` | A network or server error. A `401` means an invalid Auth Environment ID, a `redirectUrl` that is not allow-listed, or an enabled provider that is incompletely configured |

## Related

* [Google or Apple guide](../guide/client-auth#google-or-apple)
* [loginWithGoogle](./portalauthloginwithgoogle)
* [handleRedirect](./portalauthhandleredirect)
* [Apple OAuth](../../../resources/authentication/apple-oauth)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.