solved Proxima User details after loging issue.

amartins
@amartins
8 years ago
48 posts
Hello! I am developing an Android app targeting Jamroom Framework, so I am using Proxima Module to interface with server side.

I am traying to read user accounta data to verify if user still have a valid user session. I can login with no problem, I can get the user session_id to store in app preferences. But test fails when I try to use session_id to get user account, keep getting the next response:
{
"code": 401
"text": "Unauthorized"
"note": "invalid user session"
}

I am using the header Authorisation = "Basic " + Base64.encodeToString("client_key:session_id");

and the url, as logged in user id is 1, like this:
GET http://my.jamroom.site.com/api/user/1.

Is this a normal behavior of Proxima module?

If I change user id to 2, I get this response from server:
{
"code": 401
"text": "Unauthorized"
"note": "invalid item owner (0)"
}

Which is correct, as that way I'll be trying to reach someone else's account info.

If I change user id to 0 (zero), I get this:
{
"code": 400
"text": "Bad Request"
"note": "invalid user id"
}

Which is also correct, once there is no user id 0.

Is there a way to debug this? Or Am I doing something wrong?

Thanks for your time and attention.

updated by @amartins: 06/10/16 06:41:25AM
amartins
@amartins
8 years ago
48 posts
Is there a way to check if user session_id is still valid?
paul
@paul
8 years ago
4,325 posts
I've recently been checking out Proxima and have written a few simple bits of php code to test it out. Here's what I use to get user info -

        // Bring in Proxima Class
        if (!is_file(APP_DIR . "/modules/jrXProximaWidgets/contrib/Proxima.php")) {
            $_SESSION['jrXProximaWidgets_server_response'] = "ERROR: Proxima class file not found";
            jrCore_location("{$_conf['jrCore_base_url']}{$_post['url_option']}");
        }
        require_once APP_DIR . "/modules/jrXProximaWidgets/contrib/Proxima.php";
        $prx = new Proxima($_conf['jrXProximaWidgets_client_key']);
        $prx->SetProximaUrl("{$_conf['jrXProximaWidgets_proxima_url']}/api");
        $prx->SetSessionID($_SESSION['jrXProximaWidgets_local_session']['session_id']);

        // Get logged in user data
        $_rs = $prx->Get('user' . '/' . $_SESSION['jrXProximaWidgets_local_session']['_id']);

        if ($_rs && $_rs['code'] == 200) {
            // User OK
        }
        else {
            // User not on system
        }
So basically this line -

$_rs = $prx-> Get('user' . '/' . $_SESSION['jrXProximaWidgets_local_session']['_id']);

Is the "GET http://my.jamroom.site.com/api/user/x" bit where x is the Proxima user ID.

One comment on your post above is that you are requesting Proxima _id:1
There can never be a Proxima _id 1 as Proxima users are saved on the Jamroom user datastore and the Jamroom site admin will always be _user_id 1, so the minimul Proxima _id would be 2.
hth


--
Paul Asher - JR Developer and System Import Specialist
amartins
@amartins
8 years ago
48 posts
I tried with other user (11) and I get the same result. Meaning this is not a normal behavior, because expected behavior is to get own user info using client_key:session_id in header and url in the form http://my.jamroom.site.com/api/user/x, where x = logged in user id.
That is not happening...
serveion
@serveion
8 years ago
223 posts
Hello

in this video you can see, the when we try to check user session we get an invalid session response.
Proxima PostMan
amartins
@amartins
8 years ago
48 posts
I found out what happening, but need help to solve this: it fails when verifying the app_id, line 393 of "jrProximaUser-release-1.0.6/include.php", this is the code:
// Make sure we have the right app
if (!isset($_rt['_app_id']) || $_rt['_app_id'] != jrProximaCore_get_active_app_id()) {
return jrProximaCore_http_response(401, 'invalid user session - appId: ' . $appId);
}

Any idea why appd_id verification fails? (return app_id from jrProximaCore_get_active_app_id() is 4 - which is correct, is the active app)
michael
@michael
8 years ago
7,697 posts
could be because the user was not created by the app. If the user was existed by creating it on the website, not via POST then it will not have an _app_id.

Since there is no _app_id in that users datastore data that would cause the issue above.
brian
@brian
8 years ago
10,144 posts
Sorry for not jumping in here earlier - just an FYI that Proxima 2.0 is just about ready and addresses a lot of issues and adds some cool new features - one of them being a "Single Sign On" option that will allow your apps to "share" user accounts with your JR site, which I think is what will work here.

Coming very soon :)


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
amartins
@amartins
8 years ago
48 posts
Nice to hear that. I've find out the issue. Is that app_id is loaded to $_rt['_app_id'], and since there was sessions of previously delete apps in cache ($_conf.jrProximaCore_active_cache_system) the value was the first found in database with id 1, but current was 4 so not match. I deleted cache data and logged in again, now everything's working fine.

Look forward to get version 2 ;)

Thanks.
updated by @amartins: 03/09/16 04:08:46AM

Tags