Giter Site home page Giter Site logo

Signatures NEVER match. about php-sdk HOT 8 CLOSED

transloadit avatar transloadit commented on July 17, 2024
Signatures NEVER match.

from php-sdk.

Comments (8)

thisisboris avatar thisisboris commented on July 17, 2024

The code I used:

$assemblyinstructions = array(
                    'auth' => array(
                        "key" => "2b0c45611f6440dfb64611e872ec3211",
                        "expires" => "2010/10/19 09:01:20+00:00"
                    ),
                    "steps" => array(
                        "encode" => array(
                            "robot"=> "/video/encode"
                        )
                    )
                );

                // Generate signature via their PHP sdk.
                $authKey    = '2b0c45611f6440dfb64611e872ec3211';
                $authSecret = "d805593620e689465d7da6b8caf2ac7384fdb7e9";
                $transloadit = new \transloadit\Transloadit(array('key' => $authKey, 'secret' => $authSecret));
                $assembly = $transloadit->request($assemblyinstructions, false);
                $signature = $assembly->signString($assembly->getParamsString());

from php-sdk.

kvz avatar kvz commented on July 17, 2024

Hi @thisisboris, any reason you're not using an a UTC date for expiry in the future?

Also, please remove your auth & secret keys from this ticket as it's a public and community maintained sdk

from php-sdk.

thisisboris avatar thisisboris commented on July 17, 2024

Thanks for the fast reply @kvz,

This is all straight from transloadit docs, no data of mine was shown. The authsecret is a fake from the public docs. (https://transloadit.com/docs/api-docs#authentication (2.4 Example))

from php-sdk.

kvz avatar kvz commented on July 17, 2024

Ah ok : )

Have you checked out this project's readme and its examples? https://github.com/transloadit/php-sdk/blob/master/example/1-assembly-request.php

I think it handles the expiry keys itself.

Looks like you are going by the API docs, which go in depth as you should be able to build your own sdk with them, but this sdk already abstracts that logic away for convenience

from php-sdk.

thisisboris avatar thisisboris commented on July 17, 2024

It'll probably help if I expain that I'm trying to use this SDK to easily generate the signature I need. Frontend-code is AngularJS with ng-transloadit. It requires sending with signatures so I use a AJAX-get to generate my signature. However, so far all signatures have been returned as being wrong. The API-suggested php-code does not work for me. Not with templates, not without.

The SDK does indeed supply the expiry date by itself, for testing purposes I have no put the line 31 - 34 in TransloaditRequest.php in a commentblock (Where the auth-array is overridden with a more up-to-date expiry date) so that it does no longer exhibit that behavior.

I've now discovered that, when passing assembly instructions, I should pass them beneath a 'params' key (I didn't notice this in the examples before now). So that is my fault.

However, even then with the fixture (Straight from the docs):

{
  "auth": {
    "key": "dd75298ccbf7416caed06de6eca5cd27",
    "expires": "2014/06/10 10:48:38+00:00"
  },
  "steps": {
    "store": {
      "robot": "/sftp/store",
      "user": "some_user",
      "host": "example.org",
      "path": "uploads/dir/${file.url_name}"
    }
  },
  "template_id": "some_template_id"
}

Which internally creates the JSONstring and signature upon the following PHP-array:

Array
(
    [auth] => Array
        (
            [key] => dd75298ccbf7416caed06de6eca5cd27
            [expires] => "2014/06/10 10:48:38+00:00"
        )

    [steps] => Array
        (
            [store] => Array
                (
                    [robot] => /sftp/store
                    [user] => some_user
                    [host] => example.org
                    [path] => uploads/dir/${file.url_name}
                )

        )

    [template_id] => some_template_id
)

I still get the wrong signature...
Got:

da09a5fb1ac88e8fbf5c6b6f632cb131fba42c9d

Whilst the fixture-modal tells me I should get

0d6fc64c946b8e1cf057396445b98166b0ffb887

Are there any PHP.ini settings that may cause this? I do not know of one that might.

from php-sdk.

kvz avatar kvz commented on July 17, 2024

I think as of php 5.4 some options to json_encode were added if you're looking to get a signature compatible with javascript. http://www.php.net//manual/en/function.json-encode.php. E.g. iirc JSON_UNESCAPED_UNICODE is one difference with js.

Magic quotes may also impact the behavior, if you're asking about php.ini settings that could affect the functions involved.

A third possibility is you're 'contaminating' the params in javascript after the signature has been calculated.

Does that help at all?

from php-sdk.

thisisboris avatar thisisboris commented on July 17, 2024

It does, I have now a few leads to look into to find how the 'bug' is happening. Thanks a lot, if I find what it was I will post it here as a comment and close.

Thanks for the help and patience.

from php-sdk.

tim-kos avatar tim-kos commented on July 17, 2024

Closed, because this issue is 3 years old and no one else has reported anything similar.

Please feel free to re-open this if you still need help.

from php-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.