You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import Foundation
import Supabase
letsupabaseURL=URL(string:"supabase-url")!
letsupabaseKey="supabase-key"letphoneNumber="+5511999999999"letsupabase=SupabaseClient(
supabaseURL: supabaseURL,
supabaseKey: supabaseKey
)do{print("Signing in anonymously...")letsession=tryawait supabase.auth.signInAnonymously()print("Created anonymous user with id: \(session.user.id)")print("Updating phone number...")tryawait supabase.auth.update(user:UserAttributes(phone: phoneNumber))print("Updated phone number")}catch{print("Error: \(error)")}
Run:
swift run
Output:
Building for debugging...
[7/7] Applying supabase-auth-bug
Build complete! (0.77s)
Signing in anonymously...
Created anonymous user with id: E89CD5D5-A02E-4187-BF73-2BF98ED38B34
Updating phone number...
Error: api(Auth.AuthError.APIError(msg: Optional("invalid claim: missing sub claim"), code: Optional(403), error: nil, errorDescription: nil, weakPassword: nil))
Expected behavior
I expect the call to update(user:) to succeed and send an SMS to the specified phone number.
System information
OS: iOS 17.4.1 and macOS 14.4.1
Version of supabase-swift: 2.9.0
Additional context
I tried the flow above using the supabase-js library and it worked as expected. Here's the JS script for reference:
importprocessfrom'node:process';importreadlinefrom'node:readline';import{createClient}from'@supabase/supabase-js'constrl=readline.createInterface({input: process.stdin,output: process.stdout});asyncfunctionpromptForOTP(){constasyncIterator=rl[Symbol.asyncIterator]();console.log('Please, enter your OTP: ');const{ value }=awaitasyncIterator.next();returnvalue;}constsupabase=createClient('supabase-url','supabase-key')console.log('Signing in anonymously...');const{data: signInAnonymouslyData,error: signInAnonymouslyError}=awaitsupabase.auth.signInAnonymously();if(signInAnonymouslyError){console.error(signInAnonymouslyError);process.exit(1);}else{console.log('Signed in anonymously');if(signInAnonymouslyData){console.log(signInAnonymouslyData);}}constphone='+5511999999999';console.log('Sending OTP to phone...');const{data: updateUserData,error: updateUserError}=awaitsupabase.auth.updateUser({
phone
});if(updateUserError){console.error(updateUserError);process.exit(1);}else{console.log('OTP sent to phone');if(updateUserData){console.log(updateUserData);}}constphoneChangeOTP=awaitpromptForOTP();console.log('Verifying OTP...');const{data: verifyPhoneChangeOTPData,error: verifyPhoneChangeOTPError}=awaitsupabase.auth.verifyOtp({ phone,token: phoneChangeOTP,type: 'phone_change'})if(verifyPhoneChangeOTPError){console.error(verifyPhoneChangeOTPError);process.exit(1);}else{console.log('OTP verified');if(verifyPhoneChangeOTPData){console.log(verifyPhoneChangeOTPData);}}console.log('Signing out...');const{error: signOutError}=awaitsupabase.auth.signOut()if(signOutError){console.error(signOutError);process.exit(1);}else{console.log('Signed out');}console.log('Sending OTP to phone...');const{data: signInWithPhoneData,error: signInWIthPhoneError}=awaitsupabase.auth.signInWithOtp({
phone,})if(signInWIthPhoneError){console.error(signInWIthPhoneError);process.exit(1);}else{console.log('OTP sent to phone');if(signInWithPhoneData){console.log(signInWithPhoneData);}}constsmsOTP=awaitpromptForOTP();console.log('Verifying OTP...');const{data: verifySMSOTPData,error: verifySMSOTPError}=awaitsupabase.auth.verifyOtp({ phone,token: smsOTP,type: 'sms'})if(verifySMSOTPError){console.error(verifySMSOTPError);process.exit(1);}else{console.log('OTP verified');if(verifySMSOTPData){console.log(verifySMSOTPData);}}rl.close();
The text was updated successfully, but these errors were encountered:
Hi @paulofaria I was able to update the phone after anonymous sign-in. There was an issue with the auth service, fixed in supabase/auth#1580 but it is unrelated to your issue.
Bug report
Describe the bug
After performing
signInAnonymously
,update(user:)
fails with the following message:To Reproduce
Edit
Package.swift
.Edit
Sources/main.swift
.Run:
Output:
Expected behavior
I expect the call to
update(user:)
to succeed and send an SMS to the specified phone number.System information
Additional context
I tried the flow above using the supabase-js library and it worked as expected. Here's the JS script for reference:
The text was updated successfully, but these errors were encountered: