hitobito_pbs icon indicating copy to clipboard operation
hitobito_pbs copied to clipboard

Cannot get camp list using service account

Open ubervison opened this issue 2 years ago • 1 comments

Hallo zäme,

With personal API tokens being deprecated, I wanted to switch to using service accounts to access camp and participants data. With my personal API token, I can get camp and events list just fine using the REST API, which allows me to then get participation data.

Using a service account token, I can access an individual person's information from the REST API, if that person is part of the group the service account was created for. I can also access an individual event's information, as well as this event's participation list. Finally, I can access the list of event of type simple for a particular group.

However, when trying to get a particular group's list of events of type camp, I get the following response :

{
    "email": null,
    "password": null
}

This behavior concerns URLs of the form /groups/:group_id/events/camp.json.

By contrast, accessing the list of events of a simple type gives the expected response, as for this request for event of simple type at the Group level : https://db.scout.ch/fr/groups/GROUP_ID/events/simple.json or https://db.scout.ch/fr/groups/GROUP_ID/events.json

{
    "current_page": 1,
    "total_pages": 1,
    "next_page_link": null,
    "prev_page_link": null,
    "events": [
        {
            "id": "****",
            "type": "events",
            "name": "Week-end d'unité",
            "description": null,
            "motto": "",
            "cost": "",
            "maximum_participants": null,
            "participant_count": 38,
            "location": "*****",
            "application_opening_at": null,
            "application_closing_at": null,
            "application_conditions": null,
            "state": null,
            "teamer_count": 6,
            "required_contact_attrs": [],
            "hidden_contact_attrs": [],
            "external_application_link": "https://db.scout.ch/fr/groups/****/public_events/*****",
            "links": {
                "dates": [
                    "****"
                ],
                "groups": [
                    "****"
                ]
            },
            "tags": []
        }
    ],
    "linked": {
        "event_dates": [
            {
                "id": "****",
                "label": "",
                "start_at": "******",
                "finish_at": "*****",
                "location": "******"
            }
        ],
        "groups": [
            {
                "id": "*****",
                "href": "https://db.scout.ch/fr/groups/****.json",
                "group_type": "*****",
                "layer": false,
                "name": "******o",
                "short_name": "",
                "email": "*****",
                "links": {
                    "contact": "**",
                    "parent": "*****",
                    "layer_group": "****",
                    "hierarchies": [
                        "2",
                        "****",
                        "****",
                        "****"
                    ],
                    "children": [
                        .....
                    ]
                },
                "pbs_shortname": null,
                "website": "****o",
                "bank_account": "*******",
                "description": [....]",
                "available_roles": [
                    {
                        "name": "Responsable d'unité",
                        "role_class": "Group::Woelfe::Einheitsleitung"
                    },
                    {
                        "name": "Responsable adjoint·e",
                        "role_class": "Group::Woelfe::Mitleitung"
                    },
                    {
                        "name": "Administrateur·trice des adresses",
                        "role_class": "Group::Woelfe::Adressverwaltung"
                    },
                    {
                        "name": "Responsable de sizaine",
                        "role_class": "Group::Woelfe::Leitwolf"
                    },
                    {
                        "name": "Louveteau·ette",
                        "role_class": "Group::Woelfe::Wolf"
                    }
                ]
            },
            {
                "id": "*****",
                "name": "****",
                "group_type": "groupe"
            },
            {
                "id": "****",
                "name": "*****",
                "group_type": "Groupe"
            },
            {
                "id": "2",
                "name": "Pfadibewegung Schweiz",
                "group_type": "Niveau fédéral"
            },
            {
                "id": "*****",
                "name": "****",
                "group_type": "Association cantonale"
            },
            {
                "id": "****",
                "name": "*****",
                "group_type": "Louveteau·ette"
            },
            {
                "id": "****",
                "name": "******",
                "group_type": "Louveteau·ette"
            },
            {
                "id": "*****",
                "name": "*****",
                "group_type": "Louveteau·ette"
            },
            {
                "id": "****",
                "name": "*****",
                "group_type": "Louveteau·ette"
            },
            {
                "id": "*****",
                "name": "*****",
                "group_type": "Louveteau·ette"
            },
            {
                "id": "*****",
                "name": "****",
                "group_type": "Louveteau·ette"
            }
        ],
        "people": [
            {
                "id": "****",
                "first_name": "****",
                "last_name": "****",
                "nickname": "****",
                "company_name": null,
                "company": false,
                "email": "*********@***.**",
                "address": "****",
                "zip_code": "***",
                "town": "****",
                "country": null
            }
        ]
    },
    "links": {
        "groups.contact": {
            "href": "https://db.scout.ch/fr/groups/{groups.id}/people/{groups.contact}.json",
            "type": "people"
        },
        "groups.parent": {
            "href": "https://db.scout.ch/fr/groups/{groups.parent}.json",
            "type": "groups"
        },
        "groups.layer_group": {
            "href": "https://db.scout.ch/fr/groups/{groups.layer_group}.json",
            "type": "groups"
        },
        "groups.hierarchy": {
            "href": "https://db.scout.ch/fr/groups/{groups.hierarchy}.json",
            "type": "groups"
        },
        "groups.children": {
            "href": "https://db.scout.ch/fr/groups/{groups.children}.json",
            "type": "groups"
        },
        "groups.people": {
            "href": "https://db.scout.ch/fr/groups/{groups.id}/people.json",
            "type": "people"
        }
    }
}

I use redacted queries and responses for my own group because I could not find a current service API key for the test instance, apologies for the eyesore.

Thank you !

ubervison avatar Oct 07 '22 09:10 ubervison

Hi @ubervison

Thanks for the feedback!

The endpoint isn't working in the test instance as well, even with all scopes activated for the token: image

This looks like a bug to me

Michael-Schaer avatar Oct 07 '22 09:10 Michael-Schaer