API and Multi-Site

I've been handling a few support issues for Perfect World this week, which involves a lot of talk about multi-site (hub/node).

Their developers are trying to make some API calls, and I'm assisting them with this, but it comes to my attention that I don't know how the API works on multi-site.

Some questions that I have:

  • If I generate an access token on the hub, does it only apply to calls I make to the hub, or can I use that token to call any node over API?
  • Is it possible to make a call to the hub and fetch info on a user from any node? I don't see how that would be possible, but want to be sure.
  • Or am I overthinking this, and, as far as the API is concerned, each site is separate regardless of the fact that they are on a multi-site set up?

Comments

  • If I generate an access token on the hub, does it only apply to calls I make to the hub, or can I use that token to call any node over API?

    Only the hub, yes. API v2 isn't really aware of hub/node and, to my knowledge, hub/node doesn't have any special considerations for API v2. Access tokens are stored locally in each site's database. We are not currently syncing those between the hub and its nodes.

    Is it possible to make a call to the hub and fetch info on a user from any node? I don't see how that would be possible, but want to be sure.

    Your instinct is correct. This is not currently possible. It would likely require a new API endpoint in the Site Hub addon.

    Or am I overthinking this, and, as far as the API is concerned, each site is separate regardless of the fact that they are on a multi-site set up?

    Bingo. From the API perspective, each node (and hub) is a separate site. API v2 does not operate between sites at the moment.

  • Unknown
    edited May 2019

    Todd made a change last year so that the access token used in v1 that could be synced through the hub could be used to make calls in v2.

    https://github.com/vanilla/internal/pull/1501

  • Todd made a change last year so that the access token used in v1 that could be synced through the hub could be used to make calls in v2.

    This is definitely doable as of vanilla/internal#1501, but I believe it requires the Simple API addon. Unless the client absolutely requires this shared API key functionality, I recommend avoiding enabling the addon for the sole purpose of supporting it. We're trying to steer people away from Simple API (aka API v1) and towards API v2. Making Simple API a dependency for using API v2 on a site should be a last resort.