cancel
Showing results for 
Search instead for 
Did you mean: 

REST API call to get logged in customer ID

SOLVED

Re: REST API call to get logged in customer ID

Have you find the solution ?

Re: REST API call to get logged in customer ID

As you told this is third party solution.

Please put below code of paramOverrider in your webapi definition where you need customer Id.

<data>
     <parameter name="customer.id" force="true">%customer_id%</parameter>
</data>

Re: REST API call to get logged in customer ID

Magento 2 API calls

Customer Login API call:

Endpoint: http://{{BASE_URL}}/rest/default/V1/integration/customer/token

Method: POST

Header:

Content-Type : application/json

Body:

{
"username": "{customer_email_address}",
"password": "{customer_password}"
}

Status: 200 ok

Response:

"s4930bpi1up63jr14sunamtu422af3bs"   // sample bearer token 

 

API to Get Customer Information after authentication done from above API call:

End Point:  http://{{BASE_URL}}/rest/V1/customers/me 

Method: GET

Header:

Content-Type : application/json

Authorization: Bearer <token generated from Login API call>

Status: 200 ok

Response: 

{
"id": 3,
"group_id": 1,
"default_billing": "3",
"default_shipping": "3",
"created_at": "2018-08-27 06:49:52",
"updated_at": "2018-08-30 06:36:29",
"created_in": "Default Store View",
"email": "abc@gmail.com",
"firstname": "Abc",
"lastname": "Xyz",
"store_id": 1,
"website_id": 1,
"addresses": [
{
"id": 3,
"customer_id": 3,
"region": {
"region_code": "MP",
"region": "Madhya Pradesh",
"region_id": 549
},
"region_id": 549,
"country_id": "IN",
"street": [
"Lig 17",
"Gautam Nagar",
"chetak bridge"
],
"company": "",
"telephone": "",
"postcode": "560035",
"city": "Bhopal",
"firstname": "Abc",
"lastname": "Xyz",
"default_shipping": true,
"default_billing": true
}
],
"disable_auto_group_change": 0,
"extension_attributes": {
"is_subscribed": false
}
}

Re: REST API call to get logged in customer ID

not testet, but the documentation says, only ajax calls are allowed:

 

https://devdocs.magento.com/guides/v2.3/get-started/authentication/gs-authentication-session.html