5

I want to access the APIs in QuickBlox, but before that we need to authenticate our apps and get a session token, and using session token we can access the other APIs. But the problem is, when I send the authentication request using the required specification given on the QuickBloxwebsite, I am getting the error message:

{"errors":{"base":["Unexpected signature"]}}

The parameters to generate the signature is:

application_id=22&auth_key=wJHd4cQSxpQGWx5&nonce=33432&timestamp=1326966962

And then we convert it in HMAC-SHA format:

hash_hmac( 'sha1', $signatureStr , $authSecret);

Please help me to resolve this problem.

4

6 に答える 6

2

私はphpでコードスニペットを書きました、それは署名を生成します。それはうまくいきます

これは私のテストアプリケーションのクレデンシャルです:

$application_id = 92;
$auth_key = "wJHdOcQSxXQGWx5";
$authSecret = "BTFsj7Rtt27DAmT";

$nonce = rand();
echo "<br>nonce: " . $nonce;

$timestamp = time();
echo "<br>timestamp: " . $timestamp ."<br>";

$stringForSignature = "application_id=".$application_id."&auth_key=".$auth_key."&nonce=".$nonce."&timestamp=".$timestamp;
echo $stringForSignature."<br>";

$signature = hash_hmac( 'sha1', $stringForSignature , $authSecret);
echo $signature;

この助けを願っています

于 2013-01-02T19:48:16.333 に答える
2

問題が解決しました

リクエスト パラメータに問題がありました。

$params = "application_id=$application_id&auth_key=$auth_key&timestamp=$timestamp&nonce=$nonce&signature=$signature&**auth_secret=$authSecret**";

このパラメーターでは、余分なパラメーターを渡していましたが、my auth secret keyそこにあってはなりません。このパラメーターを削除したところ、機能するようになりました。

于 2013-01-03T05:05:45.683 に答える
0

1) 正しい URL にリクエストを送信する必要があります。

https://api.quickblox.com/auth.json_

代わりに https://api.quickblox.com/session.json

2) これを使用して SSL の問題を修正する必要があります。

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false)

于 2015-11-18T19:05:12.987 に答える
0

独自のアプリケーション パラメータを使用する必要があります。

  • アプリケーションID
  • 認証キー

ランダムな「ノンス」と現在のタイムスタンプ (例からではなく、このサイトhttp://www.unixtimestamp.com/index.phpで現在のタイムスタンプを取得できます)

あなたのコードは正しいですが、適切なパラメータを設定する必要があります

于 2013-01-01T18:45:00.597 に答える
0

私たちは php を使用しており、次のコードはうまく機能します。

<?php

$userLogin = '{YOUR_QB_USER}';
$userPassword = '{YOUR_QB_PASSWORD}';

$body = [
    'application_id' => '{YOUR_QB_APPLICATION_ID}',
    'auth_key' => '{YOUR_QB_AUTH_KEY}',
    'nonce' => time(),
    'timestamp' => time(),
    'user' => ['login' => $userLogin, 'password' => $userPassword]
];
$built_query = urldecode(http_build_query($body));
$signature = hash_hmac('sha1', $built_query , '{YOUR_QB_APP_SECRET}');
$body['signature'] = $signature;
$post_body = http_build_query($body);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://{YOUR_QB_HOST}/session.json');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_body);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
$token = json_decode($response, true)['session']['token'];
printf('Your token is: %s %s', $token, PHP_EOL);
于 2017-01-19T05:39:06.300 に答える