Integrating LOGIN API failed? URGENT FIXED

I need some help regarding the member session, Let me tell you the scenario: I want to use Main Site on Ghost and other sub-site on whichever platform, Once any member logged in on the Ghost website, They should be able to logged into access another subsite, Otherwise, the user can’t access the subsite if they are not logged into Ghost main site.

Please let me know how can I use the API endpoint to get the member session. I was successfully able to get admin session through the API below:
http://site-url.com/ghost/api/v4/admin/session/
is there any possibility to get a current logged-in member through below URL like:
http://site-url.com/ghost/api/v4/members/session/

/members/api/member/ will respond with a 204 if there is no user, and with a JSON object if there is a user :slight_smile:

Hi tried to get the log-in member session like this
https://site-url/ghost/api/v4/members/api/member/

But it’s not giving me any data, could you please send me the exact URL/CODE Sir if I’m doing something wrong?

The full path is /members/api/member/ - it’s not part of the Ghost API (/ghost/api/v4/...). Be sure you’re including cookies when you make the request

Thanks for your help, Yes I am now getting data of logged in member like:

{“uuid":“2ff40fda-be9e-425f-a758-d1cf99b1f1d6”,“email”:"xxxx.xx.a@gmail.com”,“name”:null,“firstname”:null,“expertise”:null,“avatar_image”:“https://www.gravatar.com/avatar/3a652cd4536a7e2d5361d1543e4865bd?s=250&r=g&d=blank",“subscribed”:false,“subscriptions”:[],“paid”:false,“created_at”:“2023-08-24T06:13:43.000Z”,“enable_comment_notifications”:true,“newsletters”:[{“id”:“64b82f7d5abe6e65258fd1a0”,“name”:"JayisGames.com Newsletter”,“description”:null,“sort_order”:0}],“email_suppression”:{“suppressed”:false,“info”:null}}

But I am not able to get it through my curl code, What steps I need to use if I want to use this json raw data into other server?

Please share what you tried, and what you got

I am using the GET Method for getting JSON data from url through curl but getting an empty response every time.

<?php $apiKey = 'a04460f67065046cee6f23444e'; $apiUrl = 'https://a.synth.dev/members/api/member/'; $ch = curl_init($apiUrl . 'users/me/'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Ghost ' . $apiKey ]); $response = curl_exec($ch); curl_close($ch); if ($response) { $userData = json_decode($response, true); print_r($userData); } else { echo 'Error fetching user data'; } ?>

You’re mixing up 2 separate concepts - the content API and the members “API”.

The members API provides information about a single member, based on their cookie. It’s not possible for the content API to determine member information, because it’s for… content.

Moreover, you’re appending users/me/ to the URL, which makes it invalid.

Hi, @vikaspotluri123

I am explaining everything now what I actually need.

Consider abc.com is GHOST based and xyz.com is non-ghost-based (in any language). I simply need the specific member data from abc.com to xyz.com.

Can you please exactly tell me how can I achieve this?

Supporting member auth on a non-ghost-based domain isn’t straightforward, so you’ll have to figure that out. Afterwards, you’ll probably need to create proxy routes for things like member info.

1 Like