Announcement

Collapse
No announcement yet.

Login API - GET App/user return response token is empty.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Login API - GET App/user return response token is empty.

    Login API - GET App/user return response token is empty.
    $siteurl -- is espocrm website.

    username : espocrm

    password :


    $client = new EspoApiClient($siteurl, $username, $password);
    $response = $client->request('GET', 'App/user');
    echo json_encode($response);

    It will response token as empty.Other fields are available.Please help me.

  • #2
    Hi ganesanjc, I think the token only works with using Espo-Authorization header. From rest api docs ( https://www.espocrm.com/documentation/development/api/ ): Basic Authentication

    For refular users EspoCRM uses Basic Authentication. Username and password/token are passed through Authorization header encoded in base64.
    "Authorization: Basic " + base64Encode(username + ':' + password)


    It's better to use auth token instead of password when you work with api. In this case you will need to provide username and password/token in Espo-Authorization header.
    "Espo-Authorization: " + base64Encode(username + ':' + passwordOrToken)
    1. Obtain an access token by GET App/user request with the username and password passed in Espo-Authorization header.
    2. Use this token instead of password in Espo-Authorization header for all further request.
    3. If the request returns 401 error that means either username/password is wrong or token is not valid anymore.

    Comment


    • ganesanjc
      ganesanjc commented
      Editing a comment
      How to pass Espo-Authorization: " + base64Encode(username + ':' + passwordOrToken) through API request

  • #3
    With EspoApiClient you can't obtain that token initially.
    Make a request manually to obtain that token first.

    Comment


    • ganesanjc
      ganesanjc commented
      Editing a comment
      which API call is used for get the token????
Working...
X