-
Notifications
You must be signed in to change notification settings - Fork 15
Description
I have an iOS app that forwards the oauth-data to meteor. I use the data to call "login", which returns
id, token, tokenExpires and type.
However, I noticed that the user wasn't set on the connection, so I added Meteor.connection.setUserId(result.id); and it worked.
However, when I close the app and open it again, I'm logged out.
That's when I noticed that the following variables are not set in local storage:
Meteor.loginToken
Meteor.loginTokenExpires
Meteor.userId
I have set these myself with the data i get from the result of the login call and that solved the issue, but I'm starting to guess I'm doing something wrong?
I also noticed that I get this on the server:
{"line":"77","file":"oauth_server.js","message":"Unable to parse state from OAuth query: ß_\u0002÷Oyø.·ëî9\u0007½\u000bp>Ó�B\u00101=ïo4","time":{"$date":1758491660022},"level":"warn"}
Exception while invoking method 'login' Error: Failed to complete OAuth handshake with Apple. invalid_grant
at getTokens (packages/quave:apple-oauth/apple_server.js:253:11)
but then I don't get an error in the response on the client.
I only get this when logging in from native login in iOS, and not when I'm logging in from the browser.
This is the code in the frontend that handles the event I get from iOS and forwards it to the login method.
window.addEventListener("native-apple-signin-success", async (event) => {
isLoadingApple = false;
const credentials = event.detail;
try {
const loginData = {
...credentials,
methodName: "native-apple",
};
if (credentials.authorizationCode) {
loginData.code = credentials.authorizationCode;
}
console.log("loginData", loginData);
let result = await Meteor.callAsync("login", loginData);
console.log("result", result);
if (result.error) {
addToast(result.error.reason || result.error.message || result.error, TOAST_TYPES.ERROR, 3000);
} else {
Meteor.connection.setUserId(result.id);
if (result.fullName?.givenName && result.fullName?.familyName) {
await Meteor.callAsync("updateName", result.fullName.givenName, result.fullName.familyName);
}
onLoginSuccess();
}
} catch (e) {
addToast(e.reason || e.message || e, TOAST_TYPES.ERROR, 3000);
}
});`