Skip to content

Commit

Permalink
add oauth2 picture claim support
Browse files Browse the repository at this point in the history
  • Loading branch information
treeben77 committed Sep 21, 2023
1 parent 7ee1ffe commit 872fd0a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
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.1"
VERSION_INFO: Literal['alpha', 'beta', 'final'] = "alpha"
VERSION: str = "1.5.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
2 changes: 2 additions & 0 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 @@ -158,6 +159,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 @@ -18,6 +18,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 872fd0a

Please sign in to comment.