Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authorization token #51

Open
andrewdubinyak opened this issue May 31, 2023 · 4 comments
Open

Authorization token #51

andrewdubinyak opened this issue May 31, 2023 · 4 comments

Comments

@andrewdubinyak
Copy link

async def add_or_update_location(request: Request, country_code: CiString(2), party_id: CiString(3),
                                 location_id: CiString(36), location: Location,
                                 crud: Crud = Depends(get_crud), adapter: Adapter = Depends(get_adapter)):
    auth_token = get_auth_token(request)

    data = await crud.get(ModuleID.locations, RoleEnum.emsp, location_id, auth_token=auth_token,
                          country_code=country_code, party_id=party_id, version=VersionNumber.v_2_2_1)
    if data:
        data = await crud.update(ModuleID.locations, RoleEnum.emsp, location.dict(), location_id,
                                 auth_token=auth_token, country_code=country_code,
                                 party_id=party_id, version=VersionNumber.v_2_2_1)
    else:
        data = await crud.create(ModuleID.locations, RoleEnum.emsp, location.dict(),
                                 auth_token, country_code=country_code,
                                 party_id=party_id, version=VersionNumber.v_2_2_1)

    return OCPIResponse(
        data=[adapter.location_adapter(data).dict()],
        **status.OCPI_1000_GENERIC_SUCESS_CODE,
    )

In this part code "module/locations/v_2_2_1/api/emsp.py" method await crud.create.
Why did you send auth_token in *args ?

@HamedAkhavan
Copy link
Collaborator

@andrewdubinyak for every crud operation, it may be necessary to know the origin of the request. That's why auth_token is always passed to crud operations. You may ignore unwanted parameters if it's not a requirement in your project.

@VictorTechs
Copy link
Collaborator

VictorTechs commented Sep 17, 2024

Hello @andrewdubinyak,
Sorry for the long response, could You tell me if Hamed's answer is satisfactory for You?

@IOR88
Copy link
Contributor

IOR88 commented Sep 22, 2024

Hi @andrewdubinyak we are now getting back to ocpi library maintenance, we will soon take care of the request you created, have you successfully integrated ocpi lib with your project ?

@andrewdubinyak
Copy link
Author

@andrewdubinyak for every crud operation, it may be necessary to know the origin of the request. That's why auth_token is always passed to crud operations. You may ignore unwanted parameters if it's not a requirement in your project.

Hi @IOR88 ! Thank for you your answer but Im finished the OCPI project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants