0

我正在尝试发布到 IBM RRC(Rational Requirements Composer)实例。我已通过 OAuth 进行身份验证,并且我的所有 Get 命令似乎都正常运行。但是,当我提交 Post 时,服务器的响应是:

Oauth authentication is required.

下面是我正在使用的 Get 和 Post 命令的示例:

这行得通

array(
  'method' => 'GET',
  'uri' => array(
    'host' => '*****',
    'port' => '*****',
    'scheme' => 'http',
    'user' => null,
    'pass' => null,
    'path' => '/rm/types/_lGrbJfq9EeKAc-rpp0B9jg',
    'query' => array(),
    'fragment' => null
   ),
   'version' => '1.1',
   'body' => '',
   'line' => 'GET /rm/types/_lGrbJfq9EeKAc-rpp0B9jg HTTP/1.1',
   'header' => 'Host: SERVERNAME
     Connection: close
     User-Agent: CakePHP
     OSLC-Core-Version: 2.0
     Accept: application/rdf+xml
     Content-Type: application/rdf+xml
     Authorization: OAuth realm="http://SERVERNAME/rm",oauth_consumer_key="49cfd21d97cf4808b730f072c902cef7",oauth_signature_method="HMAC-SHA1",oauth_signature="HjgQTj8a%2BK4VrqmaU3yiFa4rQgQ%3D",oauth_timestamp="1378405866",oauth_nonce="e91dd2cca23f429e6e45a049bb856817",oauth_token="1d45c97961754fa4b4813fd9e756c5e9",oauth_version="1.0"',
  'raw' => 'GET /rm/types/_lGrbJfq9EeKAc-rpp0B9jg HTTP/1.1
    Host: SERVERNAME
    Connection: close
    User-Agent: CakePHP
    OSLC-Core-Version: 2.0
    Accept: application/rdf+xml
    Content-Type: application/rdf+xml
    Authorization: OAuth realm="http://SERVERNAME/rm",oauth_consumer_key="49cfd21d97cf4808b730f072c902cef7",oauth_signature_method="HMAC-SHA1",oauth_signature="HjgQTj8a%2BK4VrqmaU3yiFa4rQgQ%3D",oauth_timestamp="1378405866",oauth_nonce="e91dd2cca23f429e6e45a049bb856817",oauth_token="1d45c97961754fa4b4813fd9e756c5e9",oauth_version="1.0"',
  'redirect' => false,
  'cookies' => array(),
  'proxy' => array(),
  'auth' => array()
)

这不起作用

array(
  'method' => 'POST',
  'uri' => array(
    'host' => '*****',
    'port' => '*****',
    'scheme' => 'http',
    'user' => null,
    'pass' => null,
    'path' => '/rm/requirementFactory',
    'query' => array(
      'projectURL' => 'http://SERVERPATH/jts/process/project-areas/_mBD3pfLZEeKeebKxZeYY6w'
    ),
    'fragment' => null
  ),
  'version' => '1.1',
  'body' => '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/terms/"xmlns:public_rm_10="http://www.ibm.com/xmlns/rm/public/1.0/" xmlns:calm="http://jazz.net/xmlns/prod/jazz/calm/1.0/" xmlns:rm="http://www.ibm.com/xmlns/rdm/rdf/"xmlns:acp="http://jazz.net/ns/acp#" xmlns:rm_property="http://SERVERPATH/rm/types/" xmlns:oslc="http://open-services.net/ns/core#" xmlns:nav="http://jazz.net/ns/rm/navigation#" xmlns:oslc_rm="http://open-services.net/ns/rm#"><rdf:Description rdf:about=""><rdf:type rdf:resource="http://open-services.net/ns/rm#Requirement"/><dc:description rdf:parseType="Literal">WPDP Project Document</dc:description><dc:title rdf:parseType="Literal">Mod Test</dc:title><oslc:instanceShape rdf:resource="http://SERVERPATH/rm/types/_lGrbJfq9EeKAc-rpp0B9jg"/></rdf:Description></rdf:RDF>',
  'line' => 'POST /rm/requirementFactory?projectURL=http%3A%2F%2FSERVERPATH%2Fjts%2Fprocess%2Fproject-areas%2F_mBD3pfLZEeKeebKxZeYY6w HTTP/1.1',
  'header' => 'Host: SERVERPATH
    Connection: close
    User-Agent: CakePHP
    OSLC-Core-Version: 2.0
    Accept: application/rdf+xml
    Content-Type: application/rdf+xml
    Authorization: OAuth realm="http://SERVERPATH/rm",oauth_consumer_key="49cfd21d97cf4808b730f072c902cef7",oauth_signature_method="HMAC-SHA1",oauth_signature="CW0FodwyctuRSyDTebrBfsPxAek%3D",oauth_timestamp="1378405206",oauth_nonce="abffa897607dbc1ee2a39aadf19918eb",oauth_token="1d45c97961754fa4b4813fd9e756c5e9",oauth_version="1.0"
    Content-Length: 869',
  'raw' => 'POST /rm/requirementFactory?projectURL=http%3A%2F%2FSERVERPATH%2Fjts%2Fprocess%2Fproject-areas%2F_mBD3pfLZEeKeebKxZeYY6w HTTP/1.1
    Host: SERVERPATH
    Connection: close
    User-Agent: CakePHP
    OSLC-Core-Version: 2.0
    Accept: application/rdf+xml
    Content-Type: application/rdf+xml
    Authorization: OAuth realm="http://SERVERPATH/rm",oauth_consumer_key="49cfd21d97cf4808b730f072c902cef7",oauth_signature_method="HMAC-SHA1",oauth_signature="CW0FodwyctuRSyDTebrBfsPxAek%3D",oauth_timestamp="1378405206",oauth_nonce="abffa897607dbc1ee2a39aadf19918eb",oauth_token="1d45c97961754fa4b4813fd9e756c5e9",oauth_version="1.0"
    Content-Length: 869

    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/terms/"xmlns:public_rm_10="http://www.ibm.com/xmlns/rm/public/1.0/" xmlns:calm="http://jazz.net/xmlns/prod/jazz/calm/1.0/" xmlns:rm="http://www.ibm.com/xmlns/rdm/rdf/"xmlns:acp="http://jazz.net/ns/acp#" xmlns:rm_property="http://SERVERPATH/rm/types/" xmlns:oslc="http://open-services.net/ns/core#" xmlns:nav="http://jazz.net/ns/rm/navigation#" xmlns:oslc_rm="http://open-services.net/ns/rm#"><rdf:Description rdf:about=""><rdf:type rdf:resource="http://open-services.net/ns/rm#Requirement"/><dc:description rdf:parseType="Literal">WPDP Project Document</dc:description><dc:title rdf:parseType="Literal">Mod Test</dc:title><oslc:instanceShape rdf:resource="http://SERVERPATH/rm/types/_lGrbJfq9EeKAc-rpp0B9jg"/></rdf:Description></rdf:RDF>',
  'redirect' => false,
  'cookies' => array(),
  'proxy' => array(),
  'auth' => array()
)

我希望如果 OAuth 令牌或签名无效,我会收到一个错误解释,这个错误似乎表明 OAuth 信息完全丢失。

4

1 回答 1

0

我在 IBM 的帮助下发现了这个问题。

我发送的 POST URL 包含 projectURL 的参数。此参数必须从 URL 中分离出来并包含在基本字符串中,OAuth 才能正常运行。

realm应该是不带参数的完整 url,在这种情况下http://SERVERPATH/rm/requirementFactory不是http://SERVERPATH/rm.

该站点对于发现 OAuth 签名问题非常有用:

http://hueniverse.com/2008/10/beginners-guide-to-oauth-part-iv-signing-requests/

您可以通过单击+符号将您自己的变量和令牌信息插入到站点中,并且输出会调整以向您显示您的签名和基本字符串应该是什么。

于 2013-09-10T14:21:00.157 回答