Get user data remotely (API, database, cURL)


(Jay) #1

Hello!

Please disregard any stupid questions here, I’m learning and I’m a little stuck on searching.

I’m just wondering if there is a way I can get some data (through the database (preferred), API or even cURL request).
I’m looking to grab usernames, lastips and groups from within a Java application.

For the database option, I could expose it (and protect with a firewall) and grab the data like usual through PostgreSQL?

Thanks for any help, and thank you discourse gods (creators).

EDIT, the case:
I need to get the users last ip and group by username, and then compare it to data they have provided (cross checking auth).
Not too sure about this:
curl http://DOMAIN.net/users/USER-I-WANT.json?api_key=12345567&api_username=APIUSER

I get some data and could pull the group from “custom_groups”, but there has to be a neater way.


(Erlend Sogge Heggen) #2

Normally just using the API should suffice:

You’ll have to be more specific about your use case if you want more guidance from the developers.


(Jay) #3

I’m just wondering how I would call the lastip and group fields from within a request.

I’ve updated the original with a little more information.


(Kane York) #4

Make a request for /admin/users/username.json?api_username=system&api_key=123456abcdef7890 (replace with the “all users api key” that you generate in the admin panel).


How to create an api key on the admin panel
(Jay) #5

That request is successful through my browser but it doesn’t work via the shell - it will just output “page not found”.
Tried with different API users (system and admin).

What silly mistake have I made?


(Kane York) #6

That means it’s not accepting the authentication, so it’s treating you as an anon, and anons get 404s for everything under /admin.


(Jay) #7

I thought the same would be true for different browser IPs/clean browsers/no cookies (where I haven’t logged in as an admin/user), unless I don’t understand how using the shell sends the request.


#8

Why not a proper 401?


(Kane York) #9

If my divination rod is correct, it’s because it was easier to code in Rails :stuck_out_tongue:


#10

So a 403 would require defining each route again, but with an Explicit error and no constraint? Sounds to me like constraint fails should be 401 as default, and 403 if logged in…
Seems so: Token Based Authentication in Rails - Code School Blog
That is less than optimal.


(Jay) #11

Just wondering if I could get a hint about getting data through the shell (didn’t work as per normal). I must be doing something wrong…