Guest User

Untitled

a guest
Jan 22nd, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. {"error":"no_method","error_message":"Could not find a route with 2 elements"}
  2.  
  3. $config = Drupal::config('example.settings');
  4. $instance_url = $config->get('api_url');
  5. $username = $config->get('username');
  6. $password = $config->get('password');
  7.  
  8. $auth_url = $instance_url . "/oauth2/token";
  9.  
  10. $oauth2_token_arguments = array(
  11. "grant_type" => "password",
  12. "client_id" => "example",
  13. "client_secret" => "",
  14. "username" => $username,
  15. "password" => $password,
  16. "platform" => "custom_api"
  17. );
  18.  
  19. $auth_request = curl_init($auth_url);
  20. curl_setopt($auth_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
  21. curl_setopt($auth_request, CURLOPT_HEADER, false);
  22. curl_setopt($auth_request, CURLOPT_SSL_VERIFYPEER, 0);
  23. curl_setopt($auth_request, CURLOPT_RETURNTRANSFER, 1);
  24. curl_setopt($auth_request, CURLOPT_FOLLOWLOCATION, 0);
  25. curl_setopt($auth_request, CURLOPT_HTTPHEADER, array(
  26. "Content-Type: application/json"
  27. ));
  28.  
  29. $json_arguments = json_encode($oauth2_token_arguments);
  30. curl_setopt($auth_request, CURLOPT_POSTFIELDS, $json_arguments);
  31.  
  32. $oauth2_token_response = curl_exec($auth_request);
  33.  
  34. https://example.com/rest/v10/oauth2/token?grant_type=password&username=xxxxxx&password=xxxxxx&client_id=sugar&client-secret=&platform=base
Add Comment
Please, Sign In to add comment