Giter Club home page Giter Club logo

Comments (4)

abertschi avatar abertschi commented on May 30, 2024

The second time we post our credentials we got a 403 as a response.

Please be more verbose. What is the exact response?

Edited:
Oh now i see,
you say it only crashes if

token = Token()  # the program also crashes, if you leave out this line of code

this is left out. Yes, instantiation initializes new state such as state.

A refetch feature is nonetheless optional, but feel free to suggest such feature in a pull request. There are very likely endpoints exposed to renew the session token.

from postcard_creator_wrapper.

abertschi avatar abertschi commented on May 30, 2024

In order to call fetch again without instantiating a new token, the initialization code in the constructor must be recalled.

from postcard_creator_wrapper.

wp99cp avatar wp99cp commented on May 30, 2024

Did you run the programme above?
For me, it crashes in both cases, with and without the initialization code being run again. Even if you create an entirely new object (see code below).

import time
from postcard_creator.postcard_creator import Token

token = Token()
token.fetch_token(username='...', password='...', method='swissid')
print(token.headers)

time.sleep(token.token_expires_in)  # wait until token expires

token2 = Token()  # new token object
token2.fetch_token(username='...', password='...', method='swissid')
print(token2.headers)

The error I got is the one bellow. Caused by the 403 error of the post request in line 271.

Traceback (most recent call last):
  File "D:\Projekte\postCardCreator\postcard_creator\token.py", line 283, in _get_access_token_swissid
    url = resp.json()['nextAction']['successUrl']
  File "D:\Projekte\postCardCreator\venv\lib\site-packages\requests\models.py", line 891, in json
    return complexjson.loads(
  File "C:\Python38\lib\json\__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "C:\Python38\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Python38\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Please enlighten me if I am doing something completely wrong.

from postcard_creator_wrapper.

abertschi avatar abertschi commented on May 30, 2024

Thanks for more detail. Yes I did run a sample snippet but it turned out my code was using the legacy wrapper.
Ok, this is a legitimate bug. Will flag it as such. I am currently still busy with grad school exams but I can (hopefully) look into it next week. You can increase the logging verbosity such that request and responses are traced and investigate the problem in the meantime. Otherwise I will see if I find some time next week 👍

from postcard_creator_wrapper.

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.