Back

createOAuth2Session's success URL parameter with query

  • 0
  • Apple
ashidiqidimas
30 Dec, 2023, 20:49

Hi all, so I want to use a custom URL for the success parameter, but I still want to get the session id query. Here is my current code:

TypeScript
let newSession = try await account.createOAuth2Session(
    provider: "apple",
    success: "path/{sessionId}",
)

How I can access the session id if I'm using a custom url for the success parameter?

TL;DR
The user wants to use a custom URL for the success parameter while still being able to access the session ID. They are currently using the code snippet: ```swift let newSession = try await account.createOAuth2Session( provider: "apple", success: "path/{sessionId}", ) ``` The recommend solution is to use the following URL as the success parameter: ``` appwrite-callback-[PROJECT_ID]://localhost/auth/oauth2/success ``` Alternatively, they can host their own page that redirects the user like the console does. The SDK automatically handles the session, so the user should not manually try to
Drake
30 Dec, 2023, 21:04

For apple, using our SDK, you should omit the success parameter

Drake
30 Dec, 2023, 21:04

The SDK automatically handles the session

ashidiqidimas
31 Dec, 2023, 03:54

But if I omit the success parameter, the users will see this error screen. If I pass the success parameter, this screen will not shown

jaydenclerk
31 Dec, 2023, 04:29

Happened to me

Drake
31 Dec, 2023, 05:11

What shows instead?

ashidiqidimas
31 Dec, 2023, 06:38

Nothing will be shown. It will just show the pop up to open my app, which I guess is the expected behavior? but when I open my app, it will crash because it can't get the cookies from the redirect URL

Drake
31 Dec, 2023, 18:03

You're not supposed to try and get the cookie. Appwrite SDK handles it automatically

ashidiqidimas
3 Jan, 2024, 07:19

So, do you have any suggestion on how to solve this missing redirect URL error?

Drake
3 Jan, 2024, 18:44

maybe you can use this as the success url:

TypeScript
appwrite-callback-[PROJECT_ID]://localhost/auth/oauth2/success

Either that or host your own page that redirects the user like the console does, but doesn't show the missing redirect url.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more