Comments (6)
I just forked the code in order to work on that implementation and was then realizing that just implementing setAuth
as in gotrue-js
would not work at all.
Since I have never a "old" session in my setup I would first need to somehow create a "fresh" session to just swap the accessToken
(and keep the User
etc. around).
This actually works by calling refreshSession(refreshToken: String)
but this invalidates my refresh token on my other device (as expected) where I was signed in before. It's not ideal, but it works for now.
So maybe there should be a method that takes both the access and refresh token and creates a Session
from that and extracts User
data from the JWT payload of the access token? Didn't have an extend look into what it takes to create a Session
struct.
from supabase-swift.
Hey all, I implemented the setSession
method on supabase-community/gotrue-swift#36
Can someone point supabase-swift
to feat/setSession
and test if it solves your use case?
from supabase-swift.
Hi @florivdg thanks for opening this issue.
Would this methods on gotrue-js
https://github.com/supabase/gotrue-js/blob/master/src/GoTrueClient.ts#L386-L421 solve your issue if added to gotrue-swift
?
from supabase-swift.
Hey @GRSouza thanks for your quick response!
Indeed I think this is exactly what I am looking for in order to get this to work!
from supabase-swift.
Ok, the method for setting refresh token is already implemented on gotrue-swift
, it just lacks the setAuth
.
If this is urgent for you, I think it would be faster if you could PR this change into the gotrue-swift
repository, and I'd be glad reviewing it.
If that's not blocking you now, I can do it tomorrow I think.
from supabase-swift.
I have a similar problem, however not on tvOS, but while developing an iOS App Extension for my iOS app. There's currently no mechanism in supabase-swift
to authenticate a new session using existing (unexpired) accessToken
and refreshToken
; however this functionality seem to exists in the gotrue-js
, as per comment in the linked thread.
This is due to the fact that iOS App Extensions, despite being part of the same app bundle live in separate containers that do not have access to one another.
A simple case to make sure it's clear why this is needed on iOS:
- User launches
MainApp
and signs in using email and password - User then switches to another app, for example Safari
- User finds a link they want to share to their
MainApp
account, so they tapShare
button and open iOS Share Sheet - User sees
MainApp
and taps the icon to share it. - iOS fires up
MainApp.ShareExtension
bundle and in order to execute writing data directly to Supabase usingsupabase-swift
Expected outcomes:
- App Extension re-authenticates if necessary before it can upload data to Supabase via SDK using existing credentials from the
MainApp
- User is never asked for credentials, unless the session in the
MainApp
is invalid or expired
Current outcomes:
- Unable to re-authenticate reusing existing session without logging user out from MainApp
Current workaround:
- Sending
POST
request viaURLSession
to the REST API using appropriate auth tokens. - Use CoreData with a Shared Container to add data to
MainApp
with a massive overhead to sync this data accurately when theMainApp
is re-opened, so it's not feasible at all to do this.
Notes:
- App is online-only (not offline capability, storage, or sync; just in-memory), so relies 100% on Supabase SDK
from supabase-swift.
Related Issues (20)
- Broke `StoredSession` JSON backward-compatibility HOT 2
- Failing to decode models when querying foreign tables HOT 11
- DecodingError when receiving 401 from API HOT 5
- SwiftCompile Error in Xcode 15.0 beta 5 for EventEmitter.swift from Supabase Swift SD HOT 7
- SwiftData Best Practices HOT 3
- rpc with different params type HOT 4
- createSignedURLs error in Supabase for Swift: body must have required property 'expiresIn' HOT 1
- Session.User: isAnonymous field missed HOT 1
- Can't log out deleted user with supabase.auth.signOut() HOT 1
- Edge Functions are invoked with POST only
- Incorrect parameters extracting on PKCE flow HOT 1
- Unable to update user after anonymous sign-in HOT 2
- App crashes with error: pointer being freed was not allocated
- Add examples for new way to access database HOT 2
- [Realtime] RealtimeV2 broadcastStreams skip every other "Broadcast" HOT 3
- "Could not connect to the server" using Supabase in AppClip. HOT 1
- [Auth] Add support for error codes
- Equals filter failed on column where value starts with non-alphanumeric character HOT 2
- Need proper signOut() after deleting account HOT 1
- [Auth] Add option for disabling auto refresh token
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from supabase-swift.