You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[activities] add documentation for get_activity_instance (#6981)
* Add docs for activity instance validation
* update to for new endpoint and shape
* touch up some stuff advaith noticed
* first pass Get Application Activity Instance endpoint
* add warning about channel_id and future deprecation
* fix url in curl examples
* update example in development guide
* remove channel_id, add tables for Activity Instance Object, Activity Location Object, Activity Location Kind Enum
* cleanup that json
* pnpm run fix:tables
* :s/activity-instance/activity-instances/g
* add Type column to Application Location table
---------
Co-authored-by: Matt Hova <[email protected]>
Validating activity sessions are via a Discord client before adding them to an instance's session.
99
+
</Card>
97
100
</Container>
98
101
99
102
## Assets & Metadata
@@ -887,6 +890,29 @@ This example is being done entirely on the client, however, a more common patter
887
890
888
891
---
889
892
893
+
### Preventing unwanted activity sessions
894
+
895
+
Activities are surfaced through iframes in the Discord app. The activity website itself is publicly reachable at `<application_id>.discordsays.com`. Activities will expect to be able to communicate with Discord's web or mobile client via the Discord SDK's RPC protocol. If a user loads the activity's website in a normal browser, the Discord RPC server will not be present, and the activity will likely fail in some way.
896
+
897
+
It is theoretically possible for a malicious client to mock Discord's RPC protocol or load one activity website when launching another. Because the activity is loaded inside Discord, the RPC protocol is active, and the activity is none the wiser.
898
+
899
+
To enable an activity to "lock down" activity access, we encourage utilizing the `get_activity_instance` API, found at `discord.com/api/applications/<application_id>/activity-instances/<instance_id>'`. The route requires a Bot token of the application. It returns a serialized active activity instance for the given application, if found, otherwise it returns a 404. Here are two example responses:
With this API, the activity's backend can verify that a client is in fact in an instance of that activity before allowing the client to participate in any meaningful gameplay. How an activity implements"session verification" is left to the developer's discretion. The solution can be as granular as gating specific features or as binary as not returning the activity HTML except for valid sessions.
910
+
911
+
In the below flow diagram, we show how the server can deliver the activity website, only for valid users in a valid activity instance:
Copy file name to clipboardExpand all lines: docs/resources/Application.md
+53-1Lines changed: 53 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -236,4 +236,56 @@ Edit properties of the app associated with the requesting bot user. Only propert
236
236
237
237
\* Only limited intent flags (`GATEWAY_PRESENCE_LIMITED`, `GATEWAY_GUILD_MEMBERS_LIMITED`, and `GATEWAY_MESSAGE_CONTENT_LIMITED`) can be updated via the API.
238
238
239
-
\*\* To update an Interactions endpoint URL via the API, the URL must be valid according to the [Receiving an Interaction](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/receiving-an-interaction) documentation.
239
+
\*\* To update an Interactions endpoint URL via the API, the URL must be valid according to the [Receiving an Interaction](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/receiving-an-interaction) documentation.
240
+
241
+
## Get Application Activity Instance % GET /applications/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/activity-instances/{instance_id}
242
+
243
+
Returns a serialized activity instance, if it exists. Useful for [preventing unwanted activity sessions](#DOCS_ACTIVITIES_DEVELOPMENT_GUIDES/preventing-unwanted-activity-sessions).
| application_id | snowflake |[Application](#DOCS_RESOURCES_APPLICATION/application-object) ID |
268
+
| instance_id | string | Activity [Instance](#DOCS_ACTIVITIES_DEVELOPMENT_GUIDES/activity-instance-management) ID |
269
+
| launch_id | snowflake | Unique identifier for the launch |
270
+
| location |[Activity Location](#DOCS_RESOURCES_APPLICATION/get-application-activity-instance-activity-location-object)| The Location the instance is runnning in |
271
+
| users | array of snowflakes, [user](#DOCS_RESOURCES_USER/user-object) ids | The IDs of the Users currently connected to the instance |
272
+
273
+
274
+
275
+
###### Activity Location Object
276
+
277
+
The Activity Location is an object that describes the location in which an activity instance is running.
0 commit comments