Giter VIP home page Giter VIP logo

gotrue-swift's Introduction

gotrue-swift

Warning

This repository is deprecated and it was moved to the monorepo. Repository will remain live to support old versions of the library, but any new updates MUST be done on the monorepo.

Swift client for the GoTrue API.

Using

The usage should be the same as gotrue-js except:

Oauth2:

  • signIn with OAuth2 provider only return provider url. Users have to launch that url to continue the auth flow.
  • After receiving callback uri from OAuth2 provider, use session(from url: URL) to parse session data.

Running Examples

For running the examples project you'll have to provide your own Supabase project.

$ cp Examples/Shared/Sources/_Secrets.swift Examples/Shared/Sources/Secrets.swift
$ Examples/Shared/Sources/Secrets.swift # Or use you favorite editor

Replace {PROJECT_ID} and {ANON_KEY} with real values for your project on the Supabase portal.

Check Examples for example usages.

Contributing

  • Fork the repo on GitHub
  • Clone the project to your own machine
  • Commit changes to your own branch
  • Push your work back up to your fork
  • Submit a Pull request so that we can review your changes and merge

License

This repo is licensed under MIT.

Credits

gotrue-swift's People

Contributors

angcosmin avatar awalias avatar devi-prsd avatar foodisbeast avatar grdsdev avatar harryet avatar jjlange avatar kangmingtay avatar ky1ejs avatar milesv64 avatar satishbabariya avatar thecoolwinter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gotrue-swift's Issues

sample app crashing using xcframework + bazel

I've isolated the class - and made a complete minimal example using bazel.

git clone https://github.com/wweevv-johndpope/DemoBazel/tree/supabase
./xcodegen app

you may need to enable auto signing of app

Screen Shot 2022-09-05 at 10 19 59 pm

Please help - I'm a bit behind on timelines because of this crash.

related - duplicated
binaryscraping/swift-composable-keychain#1

(it seems like because the xcframework is not around - the keychain is deallocated - and not retaining itself?)
I'm not sure the approach using self inside xcframework is doable?

UPDATE
I made this cheatsheet for bazel + XCFRAMEWORKS
there's a way to do xcframeworks via zip + sha - but for now just dumping them into repo works for me.
https://docs.google.com/presentation/d/1ZYwyA_zHjDugt4UH-APJt4qBSt_fbY_286WrgFQvdfA/edit#slide=id.p

related
supabase/supabase-swift#38

I don't know why the zombies doesn't work for these xcframeworks... that should stop the deallocation - and allow app to continue...
Screen Shot 2022-09-05 at 10 43 56 pm

UPDATE
I made some effort to rewire the classes so that a chunk is instantiate from swift file locally from app.
Good news is - it doesn't crash.

https://github.com/wweevv-johndpope/DemoBazel/tree/gotrue-swift

it's less than ideal - but can live with it for time being.
So there's no supabase.xcframework
and there's no gotrue.xcframework

The BUILD files x2 compile the swift files

Screen Shot 2022-09-05 at 11 36 26 pm

https://github.com/wweevv-johndpope/DemoBazel/tree/gotrue-swift/GoTrue

https://github.com/wweevv-johndpope/DemoBazel/tree/gotrue-swift/Thirdparty/Supabase

not the bundle is dirty and there's problem some clean up necessary but it's working locally.
We need to get the classes working within framework.

auth.session cannot decode UUID

Hi @GRSouza, I have this error when using auth.session(from:), do you have any idea what's wrong?

dataCorrupted(Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "identities", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "id", intValue: nil)], debugDescription: "Attempted to decode UUID from invalid UUID string.", underlyingError: nil))

BTW, I'm updating from 0.0.4 (no error) to 0.0.9 (error).

Also checked in Supabase logs, request has 200 response -- so no problem server-side.

clarification - I enter the secret and url

I successfully build project - run it on imac / x86

get the window

Screenshot 2023-03-21 at 2 30 22 pm

enter my email and bogus password - click register

nothing....

logs don't show anything

does this need service level secret - or anonymous key is fine?


23-03-21 13:25:59.905728+1100 Examples[29716:7817175] [API] cannot add handler to 3 from 3 - dropping
2023-03-21 13:26:03.767122+1100 Examples[29716:7817175] Warning: The selected font is a system font, but the macOS font panel will not show system fonts to the user. When configuring a text view to display rich text, you should only use fonts that are available for selection (see NSFontManager.availableFonts). A fallback font (Helvetica) will be shown to the user instead.
2023-03-21 13:26:06.212996+1100 Examples[29716:7817175] +[CATransaction synchronize] called within transaction
2023-03-21 13:26:10.488359+1100 Examples[29716:7817175] [API] cannot add handler to 3 from 3 - dropping
2023-03-21 13:26:20.799889+1100 Examples[29716:7817175] [API] cannot add handler to 3 from 3 - dropping
2023-03-21 13:26:25.257187+1100 Examples[29716:7817175] [API] cannot add handler to 3 from 3 - dropping
2023-03-21 13:26:29.102149+1100 Examples[29716:7817175] [API] cannot add handler to 3 from 3 - dropping
2023-03-21 13:29:25.971556+1100 Examples[29716:7817506] [connection] nw_read_request_report [C1] Receive failed with error "Socket is not connected"
2023-03-21 13:29:25.972588+1100 Examples[29716:7817506] [connection] nw_read_request_report [C1] Receive failed with error "Socket is not connected"
2023-03-21 13:29:25.972772+1100 Examples[29716:7817506] [connection] nw_read_request_report [C1] Receive failed with error "Socket is not connected"
2023-03-21 13:32:19.933275+1100 Examples[29716:7817175] [API] cannot add handler to 3 from 3 - dropping
2023-03-21 14:14:29.462854+1100 Examples[29716:7817175] [API] cannot add handler to 3 from 3 - dropping
2023-03-21 14:14:41.022752+1100 Examples[29716:7817175] [API] cannot add handler to 3 from 3 - dropping
2023-03-21 14:17:31.114376+1100 Examples[29716:7866026] [connection] nw_read_request_report [C3] Receive failed with error "Socket is not connected"
2023-03-21 14:17:31.114712+1100 Examples[29716:7866026] [connection] nw_read_request_report [C3] Receive failed with error "Socket is not connected"
2023-03-21 14:17:31.115106+1100 Examples[29716:7866026] [connection] nw_read_request_report [C3] Receive failed with error "Socket is not connected"
2023-03-21 14:17:44.189923+1100 Examples[29716:7817175] [API] cannot add handler to 3 from 3 - dropping
2023-03-21 14:30:23.232544+1100 Examples[29716:7817175] [API] cannot add handler to 3 from 3 - dropping
2023-03-21 14:30:49.026283+1100 Examples[29716:7817175] [API] cannot add handler to 3 from 3 - dropping

Crash on GoTrueClient initialization

Bug report

I am seeing in Crashlytics reports that the app is crashing on the GoTrueClient init. It's not a regular thing since I don't get it often but only once in a while. It's at the start of the application. I am attaching the crashlytics data:

Crashed: com.apple.root.user-initiated-qos.cooperative
0  libsystem_kernel.dylib         0x7558 __pthread_kill + 8
1  libsystem_pthread.dylib        0x7118 pthread_kill + 268
2  libsystem_c.dylib              0x1d178 abort + 180
3  libswiftCore.dylib             0x3b93a8 swift::fatalError(unsigned int, char const*, ...) + 134
4  libswiftCore.dylib             0x3b93c8 swift::warningv(unsigned int, char const*, char*) + 30
5  libswiftCore.dylib             0x3bdfd8 swift_deallocPartialClassInstance + 190
6  libswiftCore.dylib             0x3bde28 _swift_release_dealloc + 56
7  libswiftCore.dylib             0x3bec4c bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 132
8  clutch-ios                     0x156f69c assignWithTake for Environment + 96 (<compiler-generated>:96)
9  libswiftCore.dylib             0x39a83c assignWithTake for ClosedRange<>.Index + 336
10 clutch-ios                     0x156bd5c outlined assign with take of Environment? + 52436 (<compiler-generated>:52436)
11 clutch-ios                     0x156ad1c specialized GoTrueClient.init(url:headers:localStorage:configuration:) + 35 (GoTrueClient.swift:35)
12 clutch-ios                     0x1560c74 GoTrueClient.__allocating_init(url:headers:localStorage:) + 66 (GoTrueClient.swift:66)
13 clutch-ios                     0x1542e6c SupabaseClient.init(supabaseURL:supabaseKey:options:) + 84 (SupabaseClient.swift:84)
14 clutch-ios                     0xaff30 SupabaseService.init(cognitoUserID:) + 760 (<compiler-generated>:760)
15 clutch-ios                     0xafc88 SupabaseService.__allocating_init(cognitoUserID:) + 35 (SupabaseService.swift:35)
16 clutch-ios                     0x316e54 DatabaseService.__allocating_init() + 16 (DatabaseService.swift:16)
17 clutch-ios                     0x4e11c (1) suspend resume partial function for UserService.fetchUser() + 104 (UserService.swift:104)
18 libswift_Concurrency.dylib     0x41948 swift::runJobInEstablishedExecutorContext(swift::Job*) + 416
19 libswift_Concurrency.dylib     0x42868 swift_job_runImpl(swift::Job*, swift::ExecutorRef) + 72
20 libdispatch.dylib              0x15944 _dispatch_root_queue_drain + 396
21 libdispatch.dylib              0x16158 _dispatch_worker_thread2 + 164
22 libsystem_pthread.dylib        0xda0 _pthread_wqthread + 228
23 libsystem_pthread.dylib        0xb7c start_wqthread + 8
Object 0x2834215e0 deallocated with retain count 2, reference may have escaped from deinit.

A clear and concise description of what the bug is.

To Reproduce

Strat the application and the app crashes automatically.
It only happens like 15% of the times.

Expected behavior

It should start as usual.

autoRefreshToken not working

I'm currently facing the problem that users get logged out after the JWT Token expires. I assumed the Token gets automatically refreshed when the autoRefreshToken value is set to true but it doesn't.

Error:
PostgrestError(details: nil, hint: nil, code: nil, message: "JWT expired")

Additionally, some of the examples (sign in/sign out) in the README.md are not working with the newest version and other docs are missing (authEventChange for example).

Example code in the GitHub documentation on how to use GoTrue in Swift

As a Supabase user, I want to see an explicit code example in Swift, to be able to set up a basic user management within minutes and have a reference to the JS documentation.

Currently the documentation doesn't help me that much as a beginner in Swift and with no experience in JS.
I personally liked the introduction in the PostgREST (see https://github.com/supabase-community/postgrest-swift section "Usage") where you get a basic example to keep the connection to a db up and running. I was able to get data within 20 min. of work based on the PostgRest "tutorial".

I wish for a short documentation of getting started with a basic user management:

  • Create a user with Supabase by providing an e-mail-address and a password (I assume it's the default).
  • Assign a session to a user so she or he can INSERT into a db with authored access only (using Supabase RLS templates).

Auth sessions don't automatically refresh

Bug report

Describe the bug

When calling try await client.auth.session, it often throws GoTrue.GoTrueError.APIError(message: nil, msg: nil, code: nil, error: Optional("invalid_grant"), errorDescription: Optional("Invalid Refresh Token: Refresh Token Not Found") and I need to manually sign in again. This happens quite often and is undesirable behavior in a production iOS app, as the user should not have to sign back in so often.

To Reproduce

  1. Sign in with OTP sms
  2. Make plenty of authenticated server requests like so:
do {
    let session = try await self.supabaseClient.auth.session
    let accessToken = session.accessToken
    // Pass accessToken in http authorization header to custom server endpoint
}
  1. Eventually, after a day or so, the auth session will start throwing the refresh token error.

Expected behavior

The user should not have to log in again ever on iOS, unless they log out themselves. Meaning if you have logged in, try await client.auth.session should always refresh itself and give a valid session assuming no other errors.

System information

  • OS: [iOS 16.4.1]
  • Version of gotrue-swift: [e.g. 1.1.0]
  • Version of supabase-swift: [e.g. 0.2.1]

`identity_data` key not found

Bug report

Describe the bug

I'm getting Decoding error when trying to log in saying that the identity_data key is missing.

To Reproduce

Call try await client.auth.signIn(email: email, password: password)

Expected behavior

Successfully log in without an error.

System information

  • OS: iOS 16
  • Version of supabase-swift: 0.2.2

Additional context

Sign In Error: keyNotFound(CodingKeys(stringValue: "identity_data", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "user", intValue: nil), CodingKeys(stringValue: "identities", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "No value associated with key CodingKeys(stringValue: \"identity_data\", intValue: nil) (\"identity_data\").", underlyingError: nil))

json: cannot unmarshal number into Go struct field GoTrueClaims.exp of type int64

Bug report

I have created a JWT token and when I use it in supabase client with the session it throws an error. I tracked down the issue and its thrown in your library GoTrue, on setSession(accessToken: String, refreshToken: String).

The issue reported is the following:
invalid JWT: unable to parse or verify signature, json: cannot unmarshal number 1673267144.2241859 into Go struct field GoTrueClaims.exp of type int64

I am creating the token like the following:

let jwtSigner = JWTSigner.hs256(key: pKey)
let exp = Date(timeIntervalSinceNow: 3600)
let header = Header(kid: SupabaseService.SupabaseAnoKey)
let claims = SupabaseClaims(userID: userID,
                                    exp:  exp)
var supJWT = JWT(header: header, claims: claims)

To Reproduce

Create a JWT token.
Add the token to the current supabase session try await client.auth.setSession(accessToken: token, refreshToken: refreshToken)
Get the error.
invalid JWT: unable to parse or verify signature, json: cannot unmarshal number 1673267144.2241859 into Go struct field GoTrueClaims.exp of type int64

Expected behavior

It should let me do the request since the token is valid.

System information

  • OS: [e.g. macOS, Windows]: macOS Monterey (12.5.1 (21G83))
  • Version of supabase-js: [e.g. 6.0.2]: Latest (points to master)
  • Version of Node.js: [e.g. 10.10.0]

The data couldn’t be read because it isn’t in the correct format.

Hey,

currently experimenting with google authentication.
I am able to retrieve an url after the user logs in via google.
Then I am trying to get a session from this url.
But it throws me this error:

The data couldn’t be read because it isn’t in the correct format.

This is the URL I get:

myapp://callback#access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNjYwNTIyOTIxLCJzdWIiOiI0NTc1ZTgzOC03NjM4LTQ4ZjgtOGFlMC1mZGNiODk0M2E4MmMiLCJlbWFpbCI6Imdlcm5lci5iYXN0aUBnb29nbGVtYWlsLmNvbSIsInBob25lIjoiIiwiYXBwX21ldGFkYXRhIjp7InByb3ZpZGVyIjoiZW1haWwiLCJwcm92aWRlcnMiOlsiZW1haWwiLCJnb29nbGUiXX0sInVzZXJfbWV0YWRhdGEiOnsiYXZhdGFyX3VybCI6Imh0dHBzOi8vbGgzLmdvb2dsZXVzZXJjb250ZW50LmNvbS9hL0FJdGJ2bWtWWjI5d2stS0pTYVZQQVF0c19oc013Z0c3Rk54dHE5czhpNG4xPXM5Ni1jIiwiZW1haWwiOiJnZXJuZXIuYmFzdGlAZ29vZ2xlbWFpbC5jb20iLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiZnVsbF9uYW1lIjoiU2ViYXN0aWFuIEdlcm5lciIsImlzcyI6Imh0dHBzOi8vd3d3Lmdvb2dsZWFwaXMuY29tL3VzZXJpbmZvL3YyL21lIiwibmFtZSI6IlNlYmFzdGlhbiBHZXJuZXIiLCJwaWN0dXJlIjoiaHR0cHM6Ly9saDMuZ29vZ2xldXNlcmNvbnRlbnQuY29tL2EvQUl0YnZta1ZaMjl3ay1LSlNhVlBBUXRzX2hzTXdnRzdGTnh0cTlzOGk0bjE9czk2LWMiLCJwcm92aWRlcl9pZCI6IjExMTAzNDk1NjQxOTI5OTMyMDI2MCIsInN1YiI6IjExMTAzNDk1NjQxOTI5OTMyMDI2MCJ9LCJyb2xlIjoiYXV0aGVudGljYXRlZCJ9.sCPFtWFCQlFzpfx7PyobNCdnxYJqVgmTVyT5xnzg6IM&expires_in=3600&provider_token=ya29.A0AVA9y1vR1d7i6J7ag2je4YV2pS86q9d-zqsZPpUtO5VCDzZSmfAp2MPav8tGFKTexPlzwipMjDdIaGugS93FQXqJa-Ckk_x_V4GBoTdJbUT0vq90cJ_dX_B173FvKa5tFbueB6hmEBhH8IxHOmI4inliOiBYaCgYKATASATASFQE65dr83WmW95n0vDmiN7M6TAYs6w0163&refresh_token=Tp3Vto4DMhUzkonpf-rwsA&token_type=bearer

Using the latest version.
URL Types URL scheme and callbackURLScheme are set to: myapp
redirectURL and Redirect URLs in supabase are set to: myapp://callback"

Can anyone help me?

Kind regards
Sebastian Gerner

Trying to login throws error

Hello I just created a new Supabase project for testing, and tried to login using GoTrue from a new SwiftUI project, running in the iOS simulator. But it just errors out.

Bug report

Describe the bug

I tried following the README.

In my project I do:
let auth = GoTrueClient(
url: SUPABASE_URL, headers: ["apikey": SUPABASE_KEY]
)
Button("Sign Up") {
Task {
try await auth.signUp(email: "[email protected]", password: "somepassword")
}
}

A clear and concise description of what the bug is.
I see this in my device logs:
no Route matched with those values

To Reproduce

  1. Create Supabase project based on the Auth tutorial.
  2. Create SwiftUI project based on GoTrue README
  3. Notice error.

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: macOS

Decodable Issue with Idententies

Bug report

Describe the bug

So ive setup login and session refresh within our iOS app, but whenever I try to log in with auth.signIn or auth.refreshSession, this error is thrown :

Swift.DecodingError.dataCorrupted(Swift.DecodingError.Context(codingPath: [StringCodingKey(stringValue: "user", intValue: nil), StringCodingKey(stringValue: "identities", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0), StringCodingKey(stringValue: "created_at", intValue: nil)], debugDescription: "Invalid date format: 2022-11-25T00:00:00Z", underlyingError: nil))

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Use valid email & password
  2. See error

Expected behavior

Return a session object with all necessary keys & values

Screenshots

Screenshot 2023-01-06 at 11 29 21 AM

System information

  • Xcode 14.2
  • Latest Supabase Master Branch

Additional context

Im not sure if there were any recent API changes to the identities object, but it would be great to have a flag that can be passed to the login/refresh session to return a lighter session object with less metadata.

Add sign in with OpenIDConnectCredentials to the client.

It would be very handy to have in the client a public method for signing in with OpenIDConnectCredentials in order to accomplish the Apple Sign In flow.

Here is the code of the function:

@discardableResult 
public func signIn(credential: OpenIDConnectCredentials) async throws -> Session 
{
    let session = try await Env.client.send(
        Paths.token.post(
        grantType: .idToken,
        .openIDConnectCredentials(credential)
    )).value    
    if session.user.confirmedAt != nil 
    {
        try await Env.sessionManager.update(session)
        authEventChangeContinuation.yield(.signedIn)
    }
    return session
}

Support For MFA

It would be nice for the library to support MFA like the rest of Supabase.

Auth session refreshing doesn't always happen at the right time

Bug report

Describe the bug

Despite having a valid access token, gotten from calling try await client.auth.session, there have been many times where using the access token in my custom server then 401s with an error saying invalid JWT: unable to parse or verify signature, token is expired by 8s. The seconds are anywhere from 1s-60s.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. On iOS, use GoTrue client with Supabase to sign in using OTP with phone number.
  2. Every time you make a request to your custom server, do:
do {
    let session = try await self.supabaseClient.auth.session
    let accessToken = session.accessToken
    // Pass accessToken in http authorization header to custom server endpoint
    // Note that printing `session.expiresIn` invariably prints 3600
}
  1. On the server, use the given access token to call getUser
await getSupabaseAdmin().auth.getUser(accessToken)
  1. Many times, but not all the time, it will throw the expired token error. It seems to happen around the time when the JWT is expiring every hour, and then trying again in around a minute usually works. But the await auth.session should always refresh if necessary, there seems to be a bug with the timing of refreshing the session.

Expected behavior

Calling await auth.session should always give an access token which won't expire within just a few seconds.

System information

  • OS: iOS 14
  • Version of supabase-swift: 0.0.2 (GoTrue 1.1.0)
  • Version of supabase-js: 2.21.0
  • Version of Node.js: [e.g. 10.10.0]

Support Sign in With Apple

Feature request

Following on the thread in supabase/supabase#1882 and supabase/supabase#2805 I looked into adding support for AuthenticationServices and in this regard ASAuthorizationAppleIDCredential.

Is your feature request related to a problem? Please describe.

When GoTrue signs users in using SIWA they're redirected to the OAuth apple site where they sign in and eventually GoTrue received the above parameters, just through the OAuth callback flow. If this flow were to be used on iOS, it would be a very clunky UX, and could be grounds for an iOS app to be rejected from review.

Describe the solution you'd like

I started work on this here: https://github.com/catlan/gotrue-swift/commit/bac99073ad56ce6fa3257f33a22a628a135e0e9a

The problem is that the response I get:
"Invalid token: signing method RS256 is invalid"

I'm not too familiar with either Sign in With Apple nor supabase. Any clues on what is required to make this work?

getSessionFromUrl expects query but receives fragment (using ASWebAuthenticationSession)

I'm a bit confused about how this lib is supposed to be used for signing in via a Provider (e.g. Google Oauth).

As mentioned by this issue in the supabase/supabase repo (see screenshot below) callbacks come with params as a fragment, not a query.

However this lib asserts that a query is required to parse a Provider based sign-in:

func testSessionFromURL() async throws {
let url = URL(
string:
"https://dummy-url.com/callback?access_token=accesstoken&expires_in=60&refresh_token=refreshtoken&token_type=bearer"
)!
var mock = Mock.get(path: "user", json: "user")
mock.onRequest = { urlRequest, body in
let authorizationHeader = urlRequest.allHTTPHeaderFields?["Authorization"]
XCTAssertEqual(authorizationHeader, "bearer accesstoken")
}
mock.register()
let session = try await sut.session(from: url)
let expectedSession = Session(
accessToken: "accesstoken",
tokenType: "bearer",
expiresIn: 60,
refreshToken: "refreshtoken",
user: User(fromMockNamed: "user")
)
XCTAssertEqual(session, expectedSession)
}
}

So the following code fails:

func authenticate() {
  let client = SupabaseClient(supabaseUrl: host, supabaseKey: clientId)

  client.auth.signIn(provider: .google, options: .init(redirectTo: "my-app://supabase-oauth-callback", scopes: nil)) { authReslt in
    switch authReslt {
    case .success(let url):
      let session = ASWebAuthenticationSession(url: url, callbackURLScheme: "my-app") { callbackUrl, error in
        guard error == nil, let callbackUrl = callbackUrl else { return } // handle this error case

        // will fail on the line below because the url will be `my-app//supabase-oauth-callback#access_token=.....`
        // rather than `my-app//supabase-oauth-callback?access_token=.....`
        client.auth.getSessionFromUrl(url: callbackUrl.absoluteString) { sessionResult in
          switch sessionResult {
          case .success:
            // login succeeded
          case .failure:
            // handle login failure           
          }
        }
      }
      
      session.presentationContextProvider = self
      session.start()             
    case .failure:
      continuation.resume(returning: false)
    }
  }
}

This is the exact callbackUrl that this code receives:

my-app://supabase-oauth-callback#access_token=ACCESS_TOKEN&expires_in=3600&provider_token=PROVIDER_TOKEN&refresh_token=REFRESH&token_type=bearer

supabase/supabase discussions/2133

Screenshot 2022-06-08 at 23 28 30

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.