When trying to obtain an access token, with cryptotokens enabled, i get this error:
PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'token' at row 1: INSERT INTO {oauth2_server_token} (client_id, uid, type, token, expires) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array
(
[:db_insert_placeholder_0] => 1
[:db_insert_placeholder_1] => 1
[:db_insert_placeholder_2] => access
[:db_insert_placeholder_3] => eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpZCI6ImQ0YjNmNzlkM2VmMTBlZmFhN2U1MmQxZTAzYmY1NTgzMzA3ZDIyNTMiLCJjbGllbnRfaWQiOiJiaGFwaSIsInVzZXJfaWQiOiJhZG1pbiIsImV4cGlyZXMiOjE0MjE0OTc2MzIsInRva2VuX3R5cGUiOiJiZWFyZXIiLCJzY29wZSI6InVzZXJfcHJvZmlsZSJ9.cXzgfQOUJ16CPtvl8K--QmKYg3En_7gAzMoiND1qSxU5cm2iMTo3QV1gz6gIIC2TJWSWJbKUxB41bN84PkTMBA1AwFuNC76zvLWdztXYxcEDalNzTVdE5Smw8ad3H-J8a9NIc0D0ZeINvcBeeewNG9-vYQFBZdoEsuQH87BuXjNV8oQDzwCCb2m9s35nemdbDhIoVEajM0Y2NRJmN_SRvqGhHZAOtaoNUXGenPKbxsjrJGhtksdqOLhl70IO1fcsSQWrlOFllW57EXWflkVapcMSn0IYDArTJEDcDc2qT8MSL7ig4hgqa9eVEZiIQa-fXvdMlxdo8kB6WONUhI9uMQ
[:db_insert_placeholder_4] => 1421497632
)
in drupal_write_record() (line 7239 of /var/sites/default/public/includes/common.inc).
If i disable crypto tokens i get no errors and everything appears to work correctly.
See full output here: http://pastebin.com/jkA053Bk
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | oauth2_server-token_length-2409125-11.patch | 759 bytes | pjcdawkins |
| #10 | oauth2_server-token_length-2409125-10.patch | 663 bytes | pjcdawkins |
| #7 | oauth2_server-token_length-2409125-7.patch | 723 bytes | spdaly |
| #1 | oauth2_server-token_length-2409125-1.patch | 944 bytes | pjcdawkins |
Comments
Comment #1
pjcdawkins commentedThis may or may not be the right solution.
Comment #2
pjcdawkins commentedThe JWTs are not supposed to be stored in the database at all
Comment #3
pjcdawkins commentedThere is already a test case which would catch this error if merely enabling JWT (crypto) tokens was enough to reproduce it.
http://cgit.drupalcode.org/oauth2_server/tree/tests/oauth2_server.test#n582
So I suspect there is some other issue.
Comment #4
jdiggety commentedEncountered same issue. Logged in here https://www.drupal.org/node/2496219, but closed once I realised was duplicate.
Running with patch at this time, but agreed that there is no need to store JWTs in DB in the first place.
Comment #5
spdaly commentedAgree. No need to store JWT in DB.
Comment #6
spdaly commentedSo the attached patch will not work - at least with MySQL. The token field is a key in one of the indexes. When you try to alter the table like the patch, you will get an error message "BLOB/TEXT column 'token' used in key specification without a key length." You cannot put a length on a TEXT field. http://stackoverflow.com/questions/1827063/mysql-error-key-specification....
I don't have a patch file for this, but you will need to remove the token index from the table. Change the table structure (set token field to text type). And then recreate the token index using the first 255 characters of the text field.
Comment #7
spdaly commentedHere's the patch.
It drops the token index. Alters the table. Recreates the token index.
Comment #8
pjcdawkins commentedThat patch might be a workaround but the root issue (JWTs should not have storage) needs fixing too
Comment #9
pwolanin commentedThis is not the right syntax for schema API:
Comment #10
pjcdawkins commentedThis is a completely different approach. It should ensure that the library asks Drupal to store only the token ID, not the entire token.
Comment #11
pjcdawkins commentedSame as #10 but adds a comment. The automated tests won't work on Drupal.org until we find a way to install the library.
Comment #13
pjcdawkins commented