Top Menu

Jump to content
Home
    Modules
      • Projects
      • Activity
      • Work packages
      • Gantt charts
      • Calendars
      • Team planners
      • Boards
      • News
    • Getting started
    • Introduction video
      Welcome to OpenProject Community
      Get a quick overview of project management and team collaboration with OpenProject. You can restart this video from the help menu.

    • Help and support
    • Upgrade to Enterprise edition
    • User guides
    • Videos
    • Shortcuts
    • Community forum
    • Enterprise support

    • Additional resources
    • Data privacy and security policy
    • Digital accessibility (DE)
    • OpenProject website
    • Security alerts / Newsletter
    • OpenProject blog
    • Release notes
    • Report a bug
    • Development roadmap
    • Add and edit translations
    • API documentation
  • Sign in
      Forgot your password?

      or sign in with your existing account

      Google

Side Menu

  • Overview
  • Activity
    Activity
  • Roadmap
  • Work packages
    Work packages
  • Gantt charts
    Gantt charts
  • Calendars
    Calendars
  • Team planners
    Team planners
  • Boards
    Boards
  • News
  • Forums

Content

Development
  1. OpenProject
  2. Forums
  3. Development
  4. API Authentication OpenProject 5.0.19(Mysql2)

API Authentication OpenProject 5.0.19(Mysql2)

Added by GBAS Gordon over 8 years ago

Hi All,
I am attempting to use the API to return and post tasks to Open Project.
unfortunately I am unable to authenticate correctly. My session returns data accurately however when requested and following the API documentation I expected the same response in the following;

<?php

  1. An HTTP GET request example

$username= ‘a123456789b123456789c123456789d12345678e’;
$password=‘a123456789b123456789c123456789d12345678e’;
$URL=‘http://OPENPROJSERVER.ORG.AU/openproject/api/v3/projects/test’;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$URL);
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

curl_setopt($ch, CURLOPT_USERPWD, $username.“:”.$password); //Authenticate

$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code
$result=curl_exec ($ch);
print $result;
curl_close ($ch);
?>

Please advise what I am doing wrong ?
At this stage I’ve been at countless web forums and PHP examples which all do not work.

The following works successfully from a term, but not the code solution above…

curl get -u apikey:a123456789b123456789c123456789d12345678e http://OPENPROJSERVER.ORG.AU/openproject/api/v3/projects/test

Please help


Replies (1)

RE: API Authentication OpenProject 5.0.19(Mysql2) - Added by Stiv Verdugo over 8 years ago

No soy muy diestro en ingles pero menos mal la programación se sobre entiende si importar la explicación en este caso :

Sintaxis (PHP)

class OpenProject {

public $error;
public $body;
public $header;
public $token;

public function ($url){
$ch = curl_init($url);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, ‘GET’);
curl_setopt($ch, CURLOPT_USERPWD, ‘apikey:’ . $thistoken); //Autenticación $this>token=
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->_curl_timeout);
$response = curl_exec($ch);

$this->header = curl_getinfo($ch);
$error_no = curl_errno($ch);
$error = curl_error($ch);
curl_close($ch);

// Mostrar Información Retornada :
var_dump($this->body = $response);

}
}
Cualquier duda comentar.

  • (1 - 1/1)
Loading...