diff --git a/v2/thirdparty/custom-ui/thirdparty-login.mdx b/v2/thirdparty/custom-ui/thirdparty-login.mdx
index c1efaf657..696acc7f0 100644
--- a/v2/thirdparty/custom-ui/thirdparty-login.mdx
+++ b/v2/thirdparty/custom-ui/thirdparty-login.mdx
@@ -478,6 +478,7 @@ import (
func main() {
^{codeImportRecipeName}.Init(^{goModelNameForInit}.TypeInput{
Override: &^{goModelName}.OverrideStruct{
+ // highlight-start
APIs: func(originalImplementation ^{goModelName}.APIInterface) ^{goModelName}.APIInterface {
originalAppleRedirectPost := *originalImplementation.AppleRedirectHandlerPOST
@@ -511,6 +512,7 @@ func main() {
return originalImplementation
},
},
+ // highlight-end
^{goSignInUpFeatureStart}
Providers: []tpmodels.ProviderInput{
// ...
@@ -524,6 +526,60 @@ func main() {
+```python
+from supertokens_python.recipe import ^{codeImportRecipeName}
+from supertokens_python.recipe.^{codeImportRecipeName}.interfaces import APIInterface, APIOptions
+from typing import Union, Dict, Any
+from supertokens_python.recipe.thirdparty.provider import Provider, RedirectUriInfo
+
+# highlight-start
+def override_thirdparty_apis(original_implementation: APIInterface):
+ original_apple_redirect_post = original_implementation.apple_redirect_handler_post
+
+ async def apple_redirect_handler_post(
+ form_post_info: Dict[str, Any],
+ api_options: APIOptions,
+ user_context: Dict[str, Any]
+ ):
+ # form_post_info contains all the query params attached by Apple
+ state = form_post_info["state"]
+
+ # The web SDKs add a default state
+ if state is None:
+ query_items = []
+
+ for key, value in form_post_info.items():
+ query_items.append(f"{key}={value}")
+
+ query_string = "&".join(query_items)
+
+ # Refer to the README of sign_in_with_apple to understand what this url is
+ redirect_url = f"intent://callback?${query_string}#Intent;package=YOUR.PACKAGE.IDENTIFIER;scheme=signinwithapple;end"
+
+ api_options.response.set_header("Location", redirect_url)
+ api_options.response.set_status_code(303)
+ api_options.response.set_html_content("")
+ else:
+ return original_apple_redirect_post(form_post_info, api_options, user_context)
+
+ original_implementation.apple_redirect_handler_post = apple_redirect_handler_post
+ return original_implementation
+# highlight-end
+
+^{codeImportRecipeName}.init(
+ # highlight-start
+ override=^{codeImportRecipeName}.InputOverrideConfig(
+ apis=override_thirdparty_apis
+ ),
+ # highlight-end
+ ^{pythonSignInUpFeatureStart}
+ providers=[
+ # ...
+ ]
+ ^{pythonSignInUpFeatureEnd}
+)
+```
+
diff --git a/v2/thirdpartyemailpassword/custom-ui/thirdparty-login.mdx b/v2/thirdpartyemailpassword/custom-ui/thirdparty-login.mdx
index 485ffe435..288aa0409 100644
--- a/v2/thirdpartyemailpassword/custom-ui/thirdparty-login.mdx
+++ b/v2/thirdpartyemailpassword/custom-ui/thirdparty-login.mdx
@@ -481,6 +481,7 @@ import (
func main() {
^{codeImportRecipeName}.Init(^{goModelNameForInit}.TypeInput{
Override: &^{goModelName}.OverrideStruct{
+ // highlight-start
APIs: func(originalImplementation ^{goModelName}.APIInterface) ^{goModelName}.APIInterface {
originalAppleRedirectPost := *originalImplementation.AppleRedirectHandlerPOST
@@ -514,6 +515,7 @@ func main() {
return originalImplementation
},
},
+ // highlight-end
^{goSignInUpFeatureStart}
Providers: []tpmodels.ProviderInput{
// ...
@@ -527,6 +529,60 @@ func main() {
+```python
+from supertokens_python.recipe import ^{codeImportRecipeName}
+from supertokens_python.recipe.^{codeImportRecipeName}.interfaces import APIInterface, APIOptions
+from typing import Union, Dict, Any
+from supertokens_python.recipe.thirdparty.provider import Provider, RedirectUriInfo
+
+# highlight-start
+def override_thirdparty_apis(original_implementation: APIInterface):
+ original_apple_redirect_post = original_implementation.apple_redirect_handler_post
+
+ async def apple_redirect_handler_post(
+ form_post_info: Dict[str, Any],
+ api_options: APIOptions,
+ user_context: Dict[str, Any]
+ ):
+ # form_post_info contains all the query params attached by Apple
+ state = form_post_info["state"]
+
+ # The web SDKs add a default state
+ if state is None:
+ query_items = []
+
+ for key, value in form_post_info.items():
+ query_items.append(f"{key}={value}")
+
+ query_string = "&".join(query_items)
+
+ # Refer to the README of sign_in_with_apple to understand what this url is
+ redirect_url = f"intent://callback?${query_string}#Intent;package=YOUR.PACKAGE.IDENTIFIER;scheme=signinwithapple;end"
+
+ api_options.response.set_header("Location", redirect_url)
+ api_options.response.set_status_code(303)
+ api_options.response.set_html_content("")
+ else:
+ return original_apple_redirect_post(form_post_info, api_options, user_context)
+
+ original_implementation.apple_redirect_handler_post = apple_redirect_handler_post
+ return original_implementation
+# highlight-end
+
+^{codeImportRecipeName}.init(
+ # highlight-start
+ override=^{codeImportRecipeName}.InputOverrideConfig(
+ apis=override_thirdparty_apis
+ ),
+ # highlight-end
+ ^{pythonSignInUpFeatureStart}
+ providers=[
+ # ...
+ ]
+ ^{pythonSignInUpFeatureEnd}
+)
+```
+
diff --git a/v2/thirdpartypasswordless/custom-ui/thirdparty-login.mdx b/v2/thirdpartypasswordless/custom-ui/thirdparty-login.mdx
index 2484d2e1d..b6534a7a3 100644
--- a/v2/thirdpartypasswordless/custom-ui/thirdparty-login.mdx
+++ b/v2/thirdpartypasswordless/custom-ui/thirdparty-login.mdx
@@ -481,6 +481,7 @@ import (
func main() {
^{codeImportRecipeName}.Init(^{goModelNameForInit}.TypeInput{
Override: &^{goModelName}.OverrideStruct{
+ // highlight-start
APIs: func(originalImplementation ^{goModelName}.APIInterface) ^{goModelName}.APIInterface {
originalAppleRedirectPost := *originalImplementation.AppleRedirectHandlerPOST
@@ -514,6 +515,7 @@ func main() {
return originalImplementation
},
},
+ // highlight-end
^{goSignInUpFeatureStart}
Providers: []tpmodels.ProviderInput{
// ...
@@ -527,6 +529,60 @@ func main() {
+```python
+from supertokens_python.recipe import ^{codeImportRecipeName}
+from supertokens_python.recipe.^{codeImportRecipeName}.interfaces import APIInterface, APIOptions
+from typing import Union, Dict, Any
+from supertokens_python.recipe.thirdparty.provider import Provider, RedirectUriInfo
+
+# highlight-start
+def override_thirdparty_apis(original_implementation: APIInterface):
+ original_apple_redirect_post = original_implementation.apple_redirect_handler_post
+
+ async def apple_redirect_handler_post(
+ form_post_info: Dict[str, Any],
+ api_options: APIOptions,
+ user_context: Dict[str, Any]
+ ):
+ # form_post_info contains all the query params attached by Apple
+ state = form_post_info["state"]
+
+ # The web SDKs add a default state
+ if state is None:
+ query_items = []
+
+ for key, value in form_post_info.items():
+ query_items.append(f"{key}={value}")
+
+ query_string = "&".join(query_items)
+
+ # Refer to the README of sign_in_with_apple to understand what this url is
+ redirect_url = f"intent://callback?${query_string}#Intent;package=YOUR.PACKAGE.IDENTIFIER;scheme=signinwithapple;end"
+
+ api_options.response.set_header("Location", redirect_url)
+ api_options.response.set_status_code(303)
+ api_options.response.set_html_content("")
+ else:
+ return original_apple_redirect_post(form_post_info, api_options, user_context)
+
+ original_implementation.apple_redirect_handler_post = apple_redirect_handler_post
+ return original_implementation
+# highlight-end
+
+^{codeImportRecipeName}.init(
+ # highlight-start
+ override=^{codeImportRecipeName}.InputOverrideConfig(
+ apis=override_thirdparty_apis
+ ),
+ # highlight-end
+ ^{pythonSignInUpFeatureStart}
+ providers=[
+ # ...
+ ]
+ ^{pythonSignInUpFeatureEnd}
+)
+```
+