JWT Token Expiry inconsistent - php

I'm still new to laravel, api, as well as JWT. Is there anyone using tymon jwt?
I have been troubling with the Token Expiry. When ever it gets expired, it shows 2 different kinds of errors. Usually, it is just plainly {message: "token_expired"} with a status code of 401, which is fine. But, sometimes it shows up this kind of error, wherein it says it comes from a PayloadValidator, and which I could not trap where I can trigger this. It is a problem for me because its status code is 500 and our frontend developers do not want status code 500.
I would like to make it 400, or rather just have a consistent error response Is there anyone here could help me understand why there 2 kinds of error? How were these encountered?
Occurrence #1: Returns "Status 401 Unauthorized"
{
"error": "token_expired"
}
Occurrence #2: Returns "Status 500 Internal Server Error"
{
"message": "Token has expired",
"status_code": 500,
"debug": {
"line": 74,
"file": "C:\xampp\htdocs\laravel-project\vendor\tymon\jwt-auth\src\Validators\PayloadValidator.php",
"class": "Tymon\JWTAuth\Exceptions\TokenExpiredException",
"trace": [
"#0 C:\xampp\htdocs\laravel-project\vendor\tymon\jwt-auth\src\Validators\PayloadValidator.php(32): Tymon\JWTAuth\Validators\PayloadValidator->validateTimestamps(Array)",
....
}

Related

Cleartext HTTP traffic error while using http.get() method in Nativescript angular app

Iam trying to use http service to get the data from the server(I have a godaddy server where their is my file named as get_user.php).In my app iam implement a server request using NativeScriptHttpClientModule.Inside the get_user.php i have returned the data in JSON format.I just want a simple http request to be exicuted succesfully but their is error.Please help for the same, and i have used the solution provided by stackoverflow and other community
I have tried the solution to add android:usesCleartextTraffic="true"
in manifest file, but its not working.
items.component.ts method
private serverUrl = "http://portal.smallborrowing.com/get_user.php";
extractData() {
this.myService.getData(this.serverUrl).subscribe(data => this.profile=data);
console.log(this.profile);
}
item.service.ts method
getData(serverUrl) {
return this.http.get(serverUrl);
}
Error
ERROR
{
"headers": {
"normalizedNames": {},
"lazyUpdate": null,
"headers": {}
},
"status": 0,
"statusText": "Unknown Error",
"url": "http://portal.smallborrowing.com/get_user.php",
"ok": false,
"name": "HttpErrorResponse",
"message": "Http failure response for http://portal.smallborrowing.com/get_user.php: 0 Unknown Error",
"error": {
JS: "originalStack": "Error: java.io.IOException: Cleartext HTTP traffic to portal.smallborrowing.com not permitted\n at new ZoneAwareError (file:///data/data/org.nativescript.Smallborrowing/files/app/vendor.js:76023:33)\n at onRequestComplete (file:///data/data/org.nativescript.Smallborrowing/files/app/vendor.js:95301:34)\n at Object.onComplete (file:///data/data/org.nativescript.Smallborrowing/files/app/vendor.js:95290:13)",
JS: "zoneAwareStack": "Error: java.io.IOException: Cleartext HTTP traffic to portal.smallborrowing.com not permitted\n at onRequestComplete (file:///data/data/org.nativescript.Smallborrowing/files/app/vendor.js:953...
get_user.php returns this data
{"email":"John","password":"password"}

Hotelbeds API Availability Exception java.lang.StackOverflowError Without Hotelbeds SDK PHP

Trying to get hotel availability from Hotelbeds API and sometimes return Internal Server Error response :
(8 failed attempts from 20 request)
Request URL
https://api.test.hotelbeds.com/hotel-api/1.0/hotels
Request Body
https://pastebin.com/C3z2BA9Z
{"sourceMarket":"ID","stay":{"checkIn":"2018-08-17","checkOut":"2018-08-18"},"occupancies":[{"rooms":1,"adults":1,"children":0}],"hotels":{"hotel":[24196,24197,24199,24200,24202,24203,24204,24216,24217,24218,24219,24220,24221,24222,24225,24226,24227,24228,24229,24230,24340,24341,24399,24400,24401,24403,24405,24406,24407,24408,24409,24410,24411,24412,24413,24421,24422,24423,25036,25558,25559,25561,26844,26845,26846,26848,26849,53588,53589,53590,53591,53592,53594,53595,61826,61827,61829,61830,71803,71804,71807,71808,71809,71813,71815,71816,71859,71860,71863,71864,71865,71866,71867,71869,71871,71872,71875,71876,71877,71880,71881,74640,74641,75362,79813,79814,79815,79817,79818,79819,79820,79821,79822,79824,79825,79827,79828,79978,79979,79980,79981,79982,79983,79984,79985,79986,79987,80910,80918,80990,81016,81018,83482,83483,83856,83857,83859,83860,84439,84440,84441,84442,84443,84444,84445,84446,84447,92159,92160,92161,92162,92163,92165,92166,92167,92772,92773,92925,92926,92930,93195,93198,93199,93200,93203,93204,93233,93295,93297,93761,93766,93767,93768,93769,93770,94035,94115,94116,94117,94443,94470,94874,94875,95101,95614,95679,95977,95978,96173,96174,96175,96176,96178,96180,96182,96183,96184,96185,96187,96188,96189,96334,96335,96336,96337,96339,96340,96341,96343,96344,96356,96357,96358,96359,96360,96361,96365,96367,96369,96373,96374,96375,96378,96417,96418,96420,96421,96422,96423,96431,96432,96433,96434,96511,96515,96517,96518,96576,96579,96582,96588,96592,96593,96598,96600,96603,96605,96606,96607,96608,96609,96610,96611,96612,96616,96619,96621,96625,96628,96632,96633,96636,96637,96638,96641,96642,96644,96645,96651,96652,96653,96655,96658,96661,96662,96663,96664,96666,96667,96855,96883,96884,96894,96895,96899,96900,96901,96913,96914,96915,96916,96933,96934,96935,96940,96942,96955,97032,97450,97452,97454,97461,97462,97463,97476,97478,97479,98095,98602,98604,98605,98614,98616,98617,98619,98620,98621,98654,98656,98674,98675,98676,100398,100765,101255,101965,102234,102235,103062,103474,103797,103821,104194,104319,104580,104640,104644,104944,105114,105401,105555,105561,106099,106447,106643,106651,106652,106750,107183,108005,108696,109316,109403,109458,109514,110254,110360,110373,110628,110629,110630,111597,111757,111826,111852,111853,112227,112639,112640,113165,113167,113479,113480,113491,113492,113846,114593,114904,114905,114933,114934,115626,115627,115630,115632,115870,115913,116253,116254,117242,117993,118357,119798,120205,120207,120215,120602,120817,120957,121304,121318,121320,121322,121486,122047,122099,122190,122244,122391,122392,122638,122704,122931,123196,123281,123322,123804,123932,124000,124039,124041,124152,124153,124467,124753,125537,125549,126009,126010,126245,126247,126529,126678,126679,128333,128334,128335,128336,128341,128345,128383,128714,128715,128773,128845,131438,131457,131458,131460,131582,131786,131789,131791,131825,131826,131849,131850,131852,132429,132457,132458,132459,132460,132501,134083,134084,134290,134771,134777,135087,135088,135089,135101,135103,135105,135107,135115,135116,135117,135118,135159,135160,135163,135264,135265,135266,135267,135268,135867,136372,136373,136378,136379,136787,137501,137502,137503,139337,140625,141282,141283,141463,141535,142052,142054,142150,142660,142937,143698,143699,143700,143701,143702,144018,145225,145418,145500,145570,146259,146638,146708,146709,146904,146905,147036,147047,147212,147282,147283,147339,147357,147368,147369,147408,147409,147410,147562,147563,147564,147735,148365,148366,148611,148659,148763,150459,150460,150725,150726,150815,150983,150984,150985,150986,150987,150988,151343,151502,151841,151842,151940,152704,152705,152706,152708,152929,153262,153406,153424,153427,153428,153564,153765,153862,153986,154171,154320,154322,155557,155703,156038,156293,156576,156577,156578,156614,156618,156691,156969,156986,157012,157357,157417,158763,160751,160793,161057,161162,161233,161438,161579,161640,162252,162383,162947,163006,164421,164801,168919,168925,169998,171161,172456,173249,173437,173523,173524,173588,174450,175186,175187,175744,175821,176472,176771,176779,177087,177256,177912,178470,179158,179635,180127,180187,180429,180529,180530,181793,182452,182456,183250,183251,183902,183903,184048,184070,184229,184324,184327,184328,184329,184698,185029,185197,185358,185359,185724,186288,186291,186330,186773,186774,186806,187277,187493,187689,187810,188241,188242,188327,188451,188452,188694,188695,188993,189141,189472,189771,190369,190825,191452,191777,191778,191851,192260,192261,192262,192379,192380,192521,192561,194570,195504,195800,195846,196121,196595,196697,197378,198002,198170,198171,198176,198321,198917,199266,208691,208971,208997,209000,209275,209277,209279,211259,212469,212470,214638,215271,215302,215321,215334,215478,215481,215518,215574,215575,215576,215577,215608,216267,216481,216500,216501,216658,216739,216834,216836,216837,216984,217177,217611,217612,217613,217738,217781,217843,218064,218198,218341,218478,218480,218579,218580,218585,218586,218670,218671,221066,221658,221660,221663,221975,222063,222064,222110,222111,222219,222266,222336,222449,222452,222454,222456,222463,222644,222645,222994,223016,223243,223476,223674,223713,224311,224537,225945,226139,226140,226285,226288,226746,230365,231516,231517,231521,231529,231533,231534,231539,231544,233144,233145,233146,233167,233168,233214,233217,233232,233237,233238,233284,233285,233289,233290,233291,233309,233311,233314,233315,233316,233317,233318,233319,233346,233353,234391,234392,234394,234395,234396,234401,234403,234406,234407,234408,234411,234413,234414,234415,234421,234427,234428,234429,234434,234442,234464,234465,234468,234470,234474,234475,234476,234478,234481,234486,234487,234488,234492,234497,234499,234502,234503,234529,234532,234534,234535,234537,234538,234540,234543,234545,234546,234547,234549,234551,234553,234555,234558,234559,234565,234566,234568,234572,234575,234579,234582,234583,234587,234588,234591,234592,234593,234594,234595,234597,234600,234602,234603,234624,234627,234628,234630,234632,234667,235619,235620,235623,235624,235636,235645,235649,235650,235651,235655,235656,235658,235660,235661,235663,235671,235673,235675,235676,235679,235683,235684,235689,235691,235692,235696,235698,235701,235703,235705,235709,235710,235712,235714,235715,235721,235722,235723,235724,235733,235738,235741,235742,235845,236796,236974,236983,236985,236991,236997,237001,237005,237006,237010,237014,237015,237018,237019,237025,237027,237028,237029,237030,237033,237035,237048,237059,237062,237063,237073,237077,237083,237085,237090,237091,237095,237096,237102,237103,237124,237130,237131,237132,253743,253749,253757,253763,253764,253766,253767,253768,253771,253772,253775,253783,253790,253791,253798,253807,253810,253812,253819,253829,253830,253838,253847,253848,253858,253871,253890,253894,253899,253908,253916,254498,254499,254558,254670,254690,254691,254824,254945,254966,255017,255028,255040,255161,255232,255409,255494,255499,255603,255606,255607,255653,255656,255669,256337,256343,256404,256500,256530,256542,256656,256669,256885,256985,257129,257162,257282,261525,261541,261581,261692,261726,261739,261749,261778,261790,261848,261941,261944,261957,262048,262096,262123,262162,262243,262256,262277,262328,262345,262451,270823,270863,270881,271014,271109,271131,271148,271221,271304,271356,271421,271445,271487,271663,271735,271754,271808,272010,272158,272265,272289,272595,272642,272643,272777,272905,273047,273068,273114,273210,273297,273320,273324,273334,273638,273709,273758,273894,273964,274113,274142,274182,274252,274344,274475,274546,274576,274624,274800,274998,275099,275423,275497,275522,275704,275835,276092,276106,276196,276342,276385,276480,276553,276631,276818,276966,276988,277078,277358,277414,277704,277794,277909,277945,278122,278126,278157,278174,278295,278327,278391,278585,357320,357327,357408,357417,357420,357610,357665,357826,357827,357848,357902,357908,357954,357966,358004,358018,358030,358082,358083,358089,358093,358114,358160,358179,358218,361307,361308,361309,361424,361641,361815,361978,362767,363875,363876,363917,364012,364340,364470,364742,365275,365427,365429,365430,365598,365605,365606,365607,366100,366599,366711,367097,367203,367556,367637,367728,368006,368603,368738,368744,368755,368774,368836,368917,368920,368921,369061,369062,369170,369272,369340,369342,369343,369344,369345,369421,369422,369424,369426,369427,369428,369429,369434,369435,369437,369439,369440,369483,369485,369564,369839,369843,369846,370327]},"filter":{"paymentType":"AT_WEB"}}
Response Body
{
"timestamp": 1534133396201,
"status": 500,
"error": "Internal Server Error",
"exception": "java.lang.StackOverflowError",
"message": "Handler processing failed; nested exception is java.lang.StackOverflowError",
"path": "/1.0/hotels"
}
Are there any suggestions?
For someone that may experience this issue, I suggest to break hotel list to max. 500 hotels / request. It solve our issue

Why am I not getting a valid response from this REST API web service with Postman?

I have a API web URL which only accepts POST commands for searching it’s contents. I have authorized it with an API –KEY and an unique ID in the header tab of postman and put all the requires fields in the Body tab .
I am getting a response from the server saying that they got my request because I am getting a request_id back. But for some reason I am getting the response status as “ERROR”. I am not sure what’s going on . What could be the reason that’s causing the server to accept my request, but not able to reply back ? I been trying to get any response from this server that makes sense for the past 6 hours.
Here are some of the data fields I am sending the server in the Body.
{
"device_id_type": "aaid",
"device_id": "BAC9BA51-4C51-45C8-8091-3F6890A21A70",
"app_version": "1.1",
"country": "US",
"q": "hello",
"offset": 0,
"limit": 20,
"locale": "en_US",
"tz_offset": -5,
"gender": "m",
"age": "21-24",
"geo": "40.7506, 73.9935"
}
Response from the server:
{
"request_id": "ec78cd56c7da4c078d8ee5d456c52c71",
"status": "ERROR",
"data": {
"error": {
"code": 500,
"message": "An unexpected error has occured"
}
}
}
Response from server screenshot
Code Snippet from postman

Wrong response from the webhook: 400 Bad Request

I'm recently tried to use webhook to get update from telegram. my program work correctly whit getUpdates().
but when i set webhook i got
"Wrong response from the webhook: 400 Bad Request"
error when try to check status of webhook by getWebhookInfo method.
here is my code:
$telegram->commandsHandler(true)
when is used below code in getUpdates mod every thing was fine.
$telegram->commandsHandler(false)
And is should say i use https and my ssl is ok.
This is answer of getWebhookInfo to me.
{
"ok": true,
"result": {
"url": "https://telbit.ir/api/bot/<token>",
"has_custom_certificate": false,
"pending_update_count": 13,
"last_error_date": 1476344420,
"last_error_message": "Wrong response from the webhook: 400 Bad Request"
}
}
I found my answer
every things was ok. the error happens because of my framework.

PHP/cURL REST 401 / Message Failed

Okay so I get this error:
{"Code":401,
"Errors":[{
"Message":"Web request to 'http:\/\/silverstagingapi.ncrsmblab.com\/oauth2authorizationserver\/OAuth2\/Token' failed."}],
"GUID":"00000000-0000-0000-0000-000000000000",
"IsSuccessful":false,
"Message":"Web request to 'http:\/\/silverstagingapi.ncrsmblab.com\/oauth2authorizationserver\/OAuth2\/Token' failed.",
"Result":null}
IT SHOULD look like this:
{ "Code": 200,
"Errors": [],
"GUID": "00000000-0000-0000-0000-000000000000",
"IsSuccessful": true,
"Message": null,
"Result": {
"AccessToken": "gAAAACDf3PAniQx1BqJ8qKZVlTQEP7JpvOYglvk8dsBV80mWxtmRCHc1CouejnKbsXEgYbOLXjN7rdZo-Bz535wdulxgkxRTmnEBTSgdZo-DkBHrp-HeiwjlBt_uSIhH7IdIr5dU0w4M_6KgUBI5e1_GWClDHvZY8R5GQahkpy24TGAp9AAAAIAAAAA11W-Eg",
"AccessTokenExpirationUtc": "/Date(1445616318650)/",
"AccessTokenIssueDateUtc": "/Date(1445612718666)/",
"Callback": null,
"RefreshToken": null,
"Scope": [ "APIUSER" ] } }
http://pastebin.com/Ryje2B8H
StackOverflow keeps saying the code is unformatted despite Ctrl+K and code tags so I linked to a syntax-highlighted pastebin. The fact I get a JSON Response means the API is functioning / responding. But it doesn't give me anything but a 401 to go off of. I tried fsockopen() before trying curl and it flat out refused the connection. Using cURL I get a response but it fails regardless.
Figured it out. The API was limited to 3 specific software partners so it doesn't matter what keys/secrets/data I have. The API only accepts requests from specific domains or vendors it seems.

Categories