Roblox Cloud API - GroupJoinRequests

Hi all,

I am trying to interact with the new Roblox API for GroupJoinRequests. I have created an API key with the group:read and group:write permissions.

Whenever I try to interact with it, I consistently get some authentication error. Does anyone know if this is an issue because it is in beta, or am I doing something wrong?

Code snippet (in JavaScript):

const result = await axios.get(`https://apis.roblox.com/cloud/v2/groups/${groupId}/join-requests`, {
    headers: {
        "x-api-key": `${process.env.API_KEY}`,
        "Content-Type": "application/json",
    }
}).then(() => {
    console.log("SUCCESS")
}, (reject) => {
    console.log(reject.response.data)
}).catch(() => {
    console.log("ERROR")
})

Error:

{
  code: 'UNAUTHENTICATED',
  message: 'Unsupported authorization method.'
}

I have even used some open source libraries, such as Openblox, but they return the same error too.

Did you set your API_KEY as an environment variable?

        "x-api-key": `${process.env.API_KEY}`,

May aswell just put it in manually, to ensure that that isn’t the issue.

Already tried doing it as a regular string, same outcome.

Try curl, simply in a cmd shell, to make sure it isn’t to do with your API key/permissions on roblox itself.

curl -L -X GET 'https://apis.roblox.com/cloud/v2/groups/{group}/join-requests?maxPageSize=10&pageToken={string}&filter={string}' \

  -H 'x-api-key: {your-api-key}'

Encounter the same error - potentially this is a bug?

Here’s a python script that works. Output:

Group Information:
ID: {obfuscated}
Display Name: {obfuscated}
Description: {obfuscated}
Owner: users/{obfuscated}
Member Count: {obfuscated}
Public Entry Allowed: False
Locked: False
Verified: False

Group Join Requests:
Join Request Path: groups/{obfuscated}/join-requests/{obfuscated}
Created Time: 2024-07-31T21:38:47.508Z
User: users/{obfuscated}

import requests

def get_group_info(group_id, api_key):
    # Define the base URL and endpoint
    url = f'https://apis.roblox.com/cloud/v2/groups/{group_id}'

    # Set the headers, including the API key
    headers = {
        'x-api-key': api_key
    }

    try:
        # Send a GET request to the API
        response = requests.get(url, headers=headers)

        # Check if the request was successful
        response.raise_for_status()

        # Parse the JSON response
        group_info = response.json()

        return group_info

    except requests.exceptions.HTTPError as err:
        print(f"HTTP error occurred: {err}")
    except Exception as err:
        print(f"An error occurred: {err}")

def list_group_join_requests(group_id, api_key, max_page_size=10, page_token=None, user_filter=None):
    """
    Lists join requests for a specific Roblox group.
    """
    url = f'https://apis.roblox.com/cloud/v2/groups/{group_id}/join-requests'
    headers = {
        'x-api-key': api_key
    }

    params = {
        'maxPageSize': max_page_size,
    }
    
    if page_token:
        params['pageToken'] = page_token
    if user_filter:
        params['filter'] = f"user == 'users/{user_filter}'"
    
    try:
        response = requests.get(url, headers=headers, params=params)
        response.raise_for_status()
        return response.json()
    except requests.exceptions.HTTPError as err:
        print(f"HTTP error occurred: {err}")
    except Exception as err:
        print(f"An error occurred: {err}")
# Example usage
if __name__ == "__main__":
    # Replace with your actual group ID and API key
    GROUP_ID = '{obfuscated}'  # Example group ID
    API_KEY = '{obfuscated}'
    group_info = get_group_info(GROUP_ID, API_KEY)

    if group_info:
        print("Group Information:")
        print(f"ID: {group_info['id']}")
        print(f"Display Name: {group_info['displayName']}")
        print(f"Description: {group_info['description']}")
        print(f"Owner: {group_info['owner']}")
        print(f"Member Count: {group_info['memberCount']}")
        print(f"Public Entry Allowed: {group_info['publicEntryAllowed']}")
        print(f"Locked: {group_info['locked']}")
        print(f"Verified: {group_info['verified']}")
        
 # List group join requests
    join_requests = list_group_join_requests(GROUP_ID, API_KEY)

    if join_requests:
        print("\nGroup Join Requests:")
        for request in join_requests.get('groupJoinRequests', []):
            print(f"Join Request Path: {request['path']}")
            print(f"Created Time: {request['createTime']}")
            print(f"User: {request['user']}")
            print()
        
        next_page_token = join_requests.get('nextPageToken')
        if next_page_token:
            print(f"Next Page Token: {next_page_token}")

You will need the requests library.
pip install requests

Does this work? Have you tested the API key being authenticated?

I tested this. It worked. I even sent you the result.

Found the issue:
API key needed to be under a player’s account, not a group. Thanks Roblox for making that clear.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.