Skip to content

Commit

Permalink
Merge branch 'main' into groups
Browse files Browse the repository at this point in the history
  • Loading branch information
treeben77 committed Sep 27, 2023
2 parents 301c29a + 535a9ff commit ebaf98e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
copyright = '2022-2023 treeben77'
author = 'treeben77'

release = '1.4'
version = '1.4.0'
release = '1.5'
version = '1.5.0'

# -- General configuration

Expand Down
18 changes: 18 additions & 0 deletions docs/source/user.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,48 @@ User

The user's ID

The ``openid`` scope is required if authorized via `OAuth2 </oauth2>`__.

:type: int

.. attribute:: username

The user's username. This will always be ``None``, unless it is from :doc:`oauth2`

The ``openid`` and ``profile`` scopes are required if authorized via `OAuth2 </oauth2>`__.

:type: Optional[str]

.. attribute:: display_name

The user's display name. This will always be ``None``, unless it is from :doc:`oauth2`

The ``openid`` and ``profile`` scopes are required if authorized via `OAuth2 </oauth2>`__.

:type: Optional[str]

.. attribute:: headshot_uri

The URI of the user's avatar headshot. This will always be ``None``, unless it is from :doc:`oauth2`

The ``openid`` and ``profile`` scopes are required if authorized via `OAuth2 </oauth2>`__.

:type: Optional[str]

.. attribute:: created_at

The time when user's account was created. This will always be ``None``, unless it is from :doc:`oauth2`

The ``openid`` and ``profile`` scopes are required if authorized via `OAuth2 </oauth2>`__.

:type: datetime.datetime

.. attribute:: profile_uri

A link to the user's profile.

The ``openid`` scope is required if authorized via `OAuth2 </oauth2>`__.

:type: str

.. method:: upload_asset(file, asset_type, name, description, expected_robux_price=0)
Expand Down
4 changes: 2 additions & 2 deletions rblxopencloud/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Literal
import requests

VERSION: str = "1.5.2"
VERSION_INFO: Literal['alpha', 'beta', 'final'] = "alpha"
VERSION: str = "1.6.0"
VERSION_INFO: Literal['alpha', 'beta', 'final'] = "final"

user_agent: str = f"rblx-open-cloud/{VERSION} (https://github.com/treeben77/rblx-open-cloud)"

Expand Down
23 changes: 13 additions & 10 deletions rblxopencloud/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def fetch_userinfo(self) -> User:
user = User(response.json().get("id") or response.json().get("sub"), f"Bearer {self.token}")
user.username: str = response.json().get("preferred_username")
user.display_name: str = response.json().get("nickname")
user.headshot_uri: str = response.json().get("picture")
user.created_at: datetime.datetime = datetime.datetime.fromtimestamp(response.json()["created_at"]) if response.json().get("created_at") else None

if response.ok: return user
Expand Down Expand Up @@ -101,18 +102,19 @@ def fetch_resources(self) -> Resources:

experiences = []
accounts = []

for resource in response.json()["resource_infos"]:
owner = resource["owner"]
for experience_id in resource["resources"]["universe"]["ids"]:
experience = Experience(experience_id, f"Bearer {self.token}")
if owner["type"] == "User":
experience.owner = User(owner["id"], f"Bearer {self.token}")
elif owner["type"] == "Group":
experience.owner = Group(owner["id"], f"Bearer {self.token}")
experiences.append(experience)

if owner["type"] == "User":
if resource["resources"].get("universe"):
for experience_id in resource["resources"]["universe"]["ids"]:
experience = Experience(experience_id, f"Bearer {self.token}")
if owner["type"] == "User":
experience.owner = User(owner["id"], f"Bearer {self.token}")
elif owner["type"] == "Group":
experience.owner = Group(owner["id"], f"Bearer {self.token}")
experiences.append(experience)

if resource["resources"].get("creator"):
for creator_id in resource["resources"]["creator"]["ids"]:
if creator_id == "U":
accounts.append(User(owner["id"], f"Bearer {self.token}"))
Expand Down Expand Up @@ -158,6 +160,7 @@ def __init__(self, app, payload, id_token) -> None:
self.user: Optional[User] = User(id_token.get("id") or id_token.get("sub"), f"Bearer {self.token}")
self.user.username: str = id_token.get("preferred_username")
self.user.display_name: str = id_token.get("nickname")
self.user.headshot_uri: Optional[str] = id_token.get("picture")
self.user.created_at: datetime.datetime = datetime.datetime.fromtimestamp(id_token["created_at"]) if id_token.get("created_at") else None
else: self.user: Optional[User] = None

Expand Down
1 change: 1 addition & 0 deletions rblxopencloud/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(self, id: int, api_key: str) -> None:
self.id: int = id
self.display_name: Optional[str] = None
self.profile_uri: str = f"https://roblox.com/users/{self.id}/profile"
self.headshot_uri: Optional[str] = None
self.created_at: Optional[datetime.datetime] = None

self.__api_key = api_key
Expand Down

0 comments on commit ebaf98e

Please sign in to comment.