juliuste / sncf

SNCF API client
ISC License
27 stars 6 forks source link

Error 403 journeys #37

Open valdu02100 opened 5 years ago

valdu02100 commented 5 years ago

Hey

During my test with this code :

const journeys = require('sncf').journeys

journeys(frankfurt, lyon, new Date(), {duration: 24*60*60*1000})
    .then(console.log)
    .catch(console.error)

I get this error :

{ HTTPError: Response code 403 (Forbidden)
    at EventEmitter.emitter.on (C:\wamp64\www\sncf\node_modules\got\source\as-promise.js:74:19)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  name: 'HTTPError',
  host: 'www.oui.sncf',
  hostname: 'www.oui.sncf',
  method: 'POST',
  path: '/proposition/rest/search-travels/outward',
  socketPath: undefined,
  protocol: 'https:',
  url:
   'https://www.oui.sncf/proposition/rest/search-travels/outward',
  gotOptions:
   { path: '/proposition/rest/search-travels/outward',
     protocol: 'https:',
     slashes: true,
     auth: null,
     host: 'www.oui.sncf',
     port: null,
     hostname: 'www.oui.sncf',
     hash: null,
     search: null,
     query: null,
     pathname: '/proposition/rest/search-travels/outward',
     href:
      'https://www.oui.sncf/proposition/rest/search-travels/outward',
     retry:
      { retries: [Function],
        methods: [Set],
        statusCodes: [Set],
        errorCodes: [Set] },
     headers:
      { 'user-agent': 'got/9.6.0 (https://github.com/sindresorhus/got)',
        accept: 'application/json',
        'accept-encoding': 'gzip, deflate',
        'content-type': 'application/json',
        'content-length': 974 },
     hooks:
      { beforeRequest: [],
        beforeRedirect: [],
        beforeRetry: [],
        afterResponse: [],
        beforeError: [],
        init: [] },
     decompress: true,
     throwHttpErrors: true,
     followRedirect: true,
     stream: false,
     form: false,
     json: true,
     cache: false,
     useElectronNet: false,
     body:
      '{"origin":"DEFRA","originCode":"DEFRA","destination":"FRLYS","destinationCode":"FRLYS","viaCode":null,"directTravel":false,"asymmetrical":false,"professional":false,"customerAccount":false,"oneWayTravel":true,"departureDate":"2019-08-22T09:41:25","returnDate":null,"travelClass":"SECOND","country":"FR","language":"fr","busBestPriceOperator":null,"passengers":[{"travelerId":null,"profile":"ADULT","age":26,"birthDate":null,"fidelityCardType":"NONE","fidelityCardNumber":"","commercialCardNumber":null,"commercialCardType":"NONE","promoCode":"","lastName":null,"firstName":null,"phoneNumer":null,"hanInformation":null}],"animals":[],"bike":"NONE","withRecliningSeat":false,"physicalSpace":null,"fares":[],"withBestPrices":true,"highlightedTravel":null,"nextOrPrevious":false,"source":"SHOW_NEXT_RESULTS_BUTTON","targetPrice":null,"han":false,"outwardScheduleType":"BY_DEPARTURE_DATE","inwardScheduleType":"BY_DEPARTURE_DATE","currency":null,"companions":[],"$initial":false}',
     method: 'POST' },
  statusCode: 403,
  statusMessage: 'Forbidden',
  headers:
   { server: 'KCDN',
     date: 'Thu, 22 Aug 2019 07:41:26 GMT',
     'content-type': 'text/html; charset=iso-8859-1',
     'transfer-encoding': 'chunked',
     connection: 'close',
     'content-encoding': 'gzip',
     vary: 'Accept-Encoding',
     age: '0',
     'strict-transport-security': 'max-age=15768000; includeSubDomains',
     'x-cdn-srv': 'ovh-gra-cache-1' },
  body:
   '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<html><head>\n<title>403 Forbidden</title>\n</head><body>\n<h1>Forbidden</h1>\n<p>You don\'t have permission to access /proposition/rest/search-travels/outward\non this server.</p>\n</body></html>\n' }

Thanks Valentin

juliuste commented 5 years ago

Hey 🙃

First of all, thank you very much for reporting this. This module in general is currently not very well-maintained since SNCF changed stuff about their inofficial API quite frequently in the past and I didn't have the time to keep up. But it has been quite a while now since I had a look, so I might find some time to address this in the next weeks.

If I don't respond within the next two weeks, feel free to ping me again. Also - if you want to look into it yourself - I'm also happy to explain stuff.

baptisteArno commented 4 years ago

I get the same error, is there an update on this issue? @juliuste :)