Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question, authentication for asynchronous requests. #1068

Open
aman1792 opened this issue Feb 8, 2021 · 0 comments
Open

Question, authentication for asynchronous requests. #1068

aman1792 opened this issue Feb 8, 2021 · 0 comments

Comments

@aman1792
Copy link

aman1792 commented Feb 8, 2021

I encounter a problem with asynchronous requests.

I have set the token lifetime to 1 hour.
Module Version:

version = "7.x-2.16"
core = "7.x"
project = "restful"
datestamp = "1487139488"

Sometimes a Notice pops up when accessing a Resource.
Example:

\Drupal\test_api\Plugin\resource\TestResource__1_0::access
  public function access(): ?bool {
    $isAccess = parent::access();
    $isUserGrantAccess = user_access('api_create_test_content', $this->getAccount());

    if ($isAccess === FALSE || $isUserGrantAccess === FALSE) {
      throw new RestfulException(
        t(
          'You dont have access to the functionality. Contact your administrator.'
        ), 403
      );
    }

    return $isAccess && $isUserGrantAccess;
}

The $this->getAccount () method throws Notice: Trying to get property of non-object in the Drupal\restful_token_auth\Plugin\authentication\TokenAuthentication->authenticate()function

This is because
\Drupal\restful_token_auth\Plugin\authentication\TokenAuthentication
$auth_token = entity_load_single ('restful_token_auth', $id);
will return FALSE.

Additional information from the description:

entity_load_single
* @return
* The entity object, or FALSE.

You can check by putting after:

$auth_token = entity_load_single('restful_token_auth', $id);
$auth_token = FALSE;

@e0ipso What your think ?

@aman1792 aman1792 changed the title Question, authorization for asynchronous requests. Question, authentication for asynchronous requests. Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant