discord-api-docs
discord-api-docs copied to clipboard
GameSDK RelationshipManager.OnRefresh Issue: Returning 0 Relations
Description
Users are encountering a sudden issue with Discord's GameSDK, where the relationshipManager.OnRefresh callback is consistently returning 0 relations. This problem impacts developers who use this feature to create friends lists, affecting their application functionality and user experience.
Steps to Reproduce
Use the exact same code provided in Discord's documentation to generate friends lists:
var discord = new Discord.Discord(clientId, Discord.CreateFlags.Default);
var relationshipManager = discord.GetRelationshipManager();
relationshipManager.OnRefresh += () =>
{
relationshipManager.Filter((relationship) =>
{
return relationship.Type == Discord.RelationshipType.Friend;
});
Console.WriteLine("relationships updated: {0}", relationshipManager.Count());
for (var i = 0; i < relationshipManager.Count(); i++)
{
var r = relationshipManager.GetAt((uint)i);
Console.WriteLine("relationships: {0} {1}", r.Type, r.User.Username);
}
}
Expected Behavior
The result should be a number higher than 0 as the accounts running that code are confirmed to have relationships.
Current Behavior
The on refresh call returns 0 results, something that is worth noting is that the onRelationshipUpdate callback works fine so this must be an issue with the onRefresh callback only not the entire relationship manager.
The code below works fine:
relationshipManager.OnRelationshipUpdate += (ref Discord.Relationship relationship) =>
{
Console.WriteLine("User is {0}", relationship.User.Username);
}
Screenshots/Videos
No response
Client and System Information
Discord
Stable 230264 (c282a55) Host 1.0.9018 x86 (37496) Windows 10 64-Bit (10.0.22621)
System
Device name xps Processor 12th Gen Intel(R) Core(TM) i7-12700H 2.30 GHz Installed RAM 32.0 GB (31.7 GB usable) System type 64-bit operating system, x64-based processor Edition Windows 11 Home Version 22H2 OS build 22621.2283 Experience Windows Feature Experience Pack 1000.22662.1000.0
Debugging this weird issue by tapping into IPC stream itself, I have found out that GET_RELATIONSHIPS command returns
< 2024/01/07 00:26:11.000412809 length=130 from=394 to=523
01 00 00 00 7a 00 00 00 7b 22 63 6d 64 22 3a 22 ....z...{"cmd":"
47 45 54 5f 52 45 4c 41 54 49 4f 4e 53 48 49 50 GET_RELATIONSHIP
53 22 2c 22 64 61 74 61 22 3a 7b 22 63 6f 64 65 S","data":{"code
22 3a 34 30 30 36 2c 22 6d 65 73 73 61 67 65 22 ":4006,"message"
3a 22 4e 6f 74 20 61 75 74 68 65 6e 74 69 63 61 :"Not authentica
74 65 64 20 6f 72 20 69 6e 76 61 6c 69 64 20 73 ted or invalid s
63 6f 70 65 22 7d 2c 22 65 76 74 22 3a 22 45 52 cope"},"evt":"ER
52 4f 52 22 2c 22 6e 6f 6e 63 65 22 3a 22 33 31 ROR","nonce":"31
22 7d "}
For some reason discord client thinks GET_RELATIONSHIP call required by OnRefresh callback is privileged command, ends up not giving sdk friend list and therefore OnRefresh never fires.
Debugging this weird issue by tapping into IPC stream itself, I have found out that GET_RELATIONSHIPS command returns
< 2024/01/07 00:26:11.000412809 length=130 from=394 to=523 01 00 00 00 7a 00 00 00 7b 22 63 6d 64 22 3a 22 ....z...{"cmd":" 47 45 54 5f 52 45 4c 41 54 49 4f 4e 53 48 49 50 GET_RELATIONSHIP 53 22 2c 22 64 61 74 61 22 3a 7b 22 63 6f 64 65 S","data":{"code 22 3a 34 30 30 36 2c 22 6d 65 73 73 61 67 65 22 ":4006,"message" 3a 22 4e 6f 74 20 61 75 74 68 65 6e 74 69 63 61 :"Not authentica 74 65 64 20 6f 72 20 69 6e 76 61 6c 69 64 20 73 ted or invalid s 63 6f 70 65 22 7d 2c 22 65 76 74 22 3a 22 45 52 cope"},"evt":"ER 52 4f 52 22 2c 22 6e 6f 6e 63 65 22 3a 22 33 31 ROR","nonce":"31 22 7d "}
For some reason discord client thinks GET_RELATIONSHIP call required by OnRefresh callback is privileged command, ends up not giving sdk friend list and therefore OnRefresh never fires.
@appellation @afgiel Is this something you guys could assist with?
GET_RELATIONSHIP
requires the relationships.read
oauth scope
the GameSDK runs unauthenticated and this worked before, so that is a breaking change and completely breaks the gamesdk relationships functionality, especially since that is a private scope and all gamesdk functionality is public.
So this IS a bug? I'm part of a team developing extensions for a game engine and we are also facing this problem, please let us know if this will be solved soon. Clients using our engine are pressing for this bug fix from us... and apparently it's not a problem on our side then.
So this IS a bug? I'm part of a team developing extensions for a game engine and we are also facing this problem, please let us know if this will be solved soon. Clients using our engine are pressing for this bug fix from us... and apparently it's not a problem on our side then.
Yeah I've had the same issue, not sure if it's a bug or not. My guess is it's to do with the relationships.read permission. It requires approval from discord. (Not sure if the permission might have been changed or is a new permission) https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes
I contacted developer support by email to ask if this change was intentional. Unfortunately, it seems that it is.
"Unfortunately, this is intended and you will need to request permission for this scope. You can also check this link for your reference. https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes"
It would be nice if the documentation for this is updated to reflect the change.
Edit: I opened a pull request
it is not possible to perform that oauth2 authorization using the GameSDK. it's a bug that has to be fixed
Also it is a bit odd that registering RELATIONSHIP_UPDATE
event still works (and it does fire events) without any auth, but GET_RELATIONSHIPS
command requires relationships.read
.
Just want to update everyone here that after reaching out to support, I was sent the following:
We've reached out to our engineering team and there was a change to access the scope you are referring to and just to clarify that this is not a bug. Unfortunately, we cannot grant access to this scope [relationships.read] at this time.
Not really sure where to go from here. This renders this entire feature of the GameSDK as unusable. Public clarification would be appreciated.
Another update. Additionally, my application for relationships.read got denied. It seems like this feature is now inaccessible.
Thank you for your extreme patience while we investigated this internally. Upon review, this change was made as a security fix and unfortunately, the previous functionality of the scope cannot return.
My apologies for the inconvenience as I recognize this must be frustrating, but we greatly appreciate your respect and understanding for the safety and security of Discord Apps, Developers, and Users!