Closed TobiasPott closed 5 months ago
@SMArhamsoft can you tell me what exactly you are trying to do. As far as I understand it you want your app to retrieve data from your server and a user of your app does not have a specific account/parse user which you would use inside the SDK to login. You are asking how you would achieve this without the login of a user, correct? I've a few questions to understand your goal a bit better. Does a user of your app never has a individual parse user associated with it or might that be the case in the future or is it an optional thing and app users may login but could also choose to not to and still need to retrieve data from your backend?
Assuming you don't want your users to ever have individual parse user accounts I would suggest to create a single parse user (I think of it as a 'guest' user) on your backend with the permission to read and write of your classes depending on what your app needs to do (I'm not sure what default permissions are but I think any user can create, query, edit and delete any custom ParseObject). Use that user to call the Login method from the SDK. This will make any user of your app use the same parse user, but unless you don't need to distinguish between them on a per user level, it would be fine.
Currently I am doing exactly what you have suggested. I had created a guest user and everyone can retrieve data. I was looking for a better way to not create any user as it is not required to login and it is not even prompted to the user to login as guest or anything. I have hardcoded the login with the same credentials for now. In the last sdk which I was using there wasn't any mandatory requirement to login before retrieving data as I have made all my ParseObjects in my class accessible to everyone.
I was just asking if there is any way to access data from my class without any Parse user login as it was in the previous sdk that I was using. If not then thats fine as well as I am still able to retrieve data from my class.
Thank you for helping me out with the configuration
(New to Parse, using Back4App) Am I to understand that an app cannot get data with objectID from the server if it's not authenticated?
ParseQuery<ParseObject> query = ParseClient.Instance.GetQuery(_DeviceClass);
query.GetAsync(deviceId).ContinueWith(GetDeviceCallback);
This code is throwing in the callback the exception “System.NullReferenceException: Object reference not set to an instance of an object” at Parse.Platform.Queries.ParseQueryController+<>c__DisplayClass7_0`1[T].
I am able to write to the database, and refresh/fetch the newly created ParseObject.
Also, if I have a user logged in before I try, the code succeeds in loading, but if i don’t (either haven’t logged in or have logged out) then the the exception is thrown.
I will check this out.
(New to Parse, using Back4App) Am I to understand that an app cannot get data with objectID from the server if it's not authenticated?
ParseQuery<ParseObject> query = ParseClient.Instance.GetQuery(_DeviceClass); query.GetAsync(deviceId).ContinueWith(GetDeviceCallback);
This code is throwing in the callback the exception “System.NullReferenceException: Object reference not set to an instance of an object” at Parse.Platform.Queries.ParseQueryController+<>c__DisplayClass7_0`1[T].b__1 (System.Object item) [0x00000] in //Parse-SDK-dotNET-2.0.0-develop-1/Parse/Platform/Queries/ParseQueryController.cs:29
I am able to write to the database, and refresh/fetch the newly created ParseObject.
Also, if I have a user logged in before I try, the code succeeds in loading, but if i don’t (either haven’t logged in or have logged out) then the the exception is thrown.
This is the way SDK was made. It requires ParseUser object to make a request to a server. At this moment my SDK knowledge level is not enough to determine an exact reason why it was made in this way. However, it looks like a mistake because the server allows public access permission and allows to retrieve data with public access using postman without user authentication.
@SMArhamsoft can you tell me what exactly you are trying to do. As far as I understand it you want your app to retrieve data from your server and a user of your app does not have a specific account/parse user which you would use inside the SDK to login. You are asking how you would achieve this without the login of a user, correct? I've a few questions to understand your goal a bit better. Does a user of your app never has a individual parse user associated with it or might that be the case in the future or is it an optional thing and app users may login but could also choose to not to and still need to retrieve data from your backend?
Assuming you don't want your users to ever have individual parse user accounts I would suggest to create a single parse user (I think of it as a 'guest' user) on your backend with the permission to read and write of your classes depending on what your app needs to do (I'm not sure what default permissions are but I think any user can create, query, edit and delete any custom ParseObject). Use that user to call the Login method from the SDK. This will make any user of your app use the same parse user, but unless you don't need to distinguish between them on a per user level, it would be fine.
Is concurrent use of the guest user by different clients allowed? Example scenario: multiple instances of a mobile client that try to get some data that should be available in the mobile app without SignUp or SignIn.
If this is still in interest, I found the underlying bug for this issue. Rootcause is a missing null check on ../Parse-SDK-dotNET/Parse/Platform/Queries/ParseQueryController.cs Line 29 at the very end. user.Services -> user is null.
I have pushed a PR with the code fix suggestion here.
works on .NET MAUI, tested on iOS, and MacCatalyst
Thank you for the release. I am now able to build apk and it is running perfectly fine on Android platform. The only thing that I wasn't able to configure correctly was to access data without logging in. I don't want to login as it is not a requirement for my project. Without the login it just gets stuck in the loop from where I need to get ParseObjects from the class. I would appreciate if you can help me in this matter.
Originally posted by @SMArhamsoft in https://github.com/parse-community/Parse-SDK-dotNET/issues/331#issuecomment-656065612
Additional info from previous thread: The platform used is Unity targeting Android mobile devices. The problem described above may not be related to the platform specifically but may require such info for reproduction or clarification.