Sorry should have replied here... not comment...I tried changing the environment to 'production' but the button still isnt working. do you need any other code?
Here is my js code
//* CONFIGURING CLOUDKIT & ICLOUD USER AUTHENTICATION
CloudKit.configure ({
containers: [{
containerId: process.env.ICLOUD_CONTAINER,
apiTokenAuth: {
apiToken: process.env.ICLOUD_API_KEY,
persist: true, // keeps user signed in after closing/reopening browser
useAuth: true
},
environment: 'development' // or 'production'
}]
});
// Logging process.env values
function main() {
console.log(process.env.ICLOUD_CONTAINER);
console.log(process.env.ICLOUD_API_KEY);
console.log(process.env.ICLOUD_REDIRECT_URI);
}
document.addEventListener("DOMContentLoaded", main);
CloudKit.on('error', (error) => {
console.error(error);
});
CloudKit.getAuthStatus().then(function(response) {
if(response.status === 'AUTHORIZED') {
console.log('User is already signed in');
landingPage.classList.add("hide");
flashCardPage.classList.remove("hide");
fetchAlbums();
} else {
console.log('User is not signed in');
signInBtn.addEventListener("click", () => {
CloudKit.signIn({
scope: 'email',
redirectURI: process.env.ICLOUD_REDIRECT_URI
}).then((response) => {
console.log(response);
if(response.isSuccess) {
landingPage.classList.add("hide");
flashCardPage.classList.remove("hide");
userIdentity = response.userIdentity;
fetchAlbums();
} else {
console.error('Error signing in:', response.error);
};
});
});
};
});