Skip to main content

GET_getByAccessToken

await client.GET_getByAccessToken(authorization: str, cluster: Optional[str] = None)
Get account information for the authenticated user using an OAuth access token. This method retrieves the account associated with the provided authorization token.

Parameters

authorization
str
required
The OAuth access token. Should be in the format Bearer <token> or just the token string.
cluster
str
The cluster to retrieve from. If not provided, uses the client’s default cluster.Valid clusters:
  • americas
  • asia
  • esports
  • europe

Returns

AccountDto
object
Account information object for the authenticated user (or raw dict if raw_data=True).

Exceptions

  • InvalidCluster - If the provided cluster is invalid
  • RiotAPIResponseError - If the API response indicates an error (e.g., invalid token, expired token)

Example

import asyncio
from valaw import Client

async def main():
    client = Client(
        token="RGAPI-your-api-key-here",
        cluster="americas"
    )
    
    try:
        # Get account using OAuth access token
        access_token = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
        
        account = await client.GET_getByAccessToken(
            authorization=access_token
        )
        
        print(f"Authenticated as: {account.gameName}#{account.tagLine}")
        print(f"PUUID: {account.puuid}")
        
    except Exception as e:
        print(f"Error: {e}")
    finally:
        await client.close()

asyncio.run(main())

Example with Riot Sign-On (RSO)

import asyncio
from valaw import Client

async def main():
    client = Client(
        token="RGAPI-your-api-key-here",
        cluster="americas"
    )
    
    try:
        # Step 1: Create RSO authorization link
        rso_link = client.create_RSO_link(
            redirect_uri="http://localhost:3000/callback",
            client_id="your-client-id",
            response_type="code",
            scopes=["openid", "cpid"]
        )
        
        print(f"Authorize at: {rso_link}")
        
        # Step 2: After user authorizes, exchange code for access token
        # (This step typically happens in your OAuth callback handler)
        access_token = "Bearer <token-from-oauth-flow>"
        
        # Step 3: Get authenticated user's account
        account = await client.GET_getByAccessToken(
            authorization=access_token
        )
        
        print(f"User: {account.gameName}#{account.tagLine}")
        
    finally:
        await client.close()

asyncio.run(main())

Example Token Format

# With Bearer prefix
authorization = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U"

# Or just the token
authorization = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U"

Response Example

AccountDto(
    puuid="abc123-def456-ghi789-jkl012",
    gameName="AuthenticatedPlayer",
    tagLine="NA1"
)
This endpoint is useful for applications that implement Riot Sign-On (RSO) authentication, allowing users to log in with their Riot account and retrieve their own account information.
Never expose access tokens in client-side code or logs. Always handle tokens securely and use HTTPS for transmission.

Build docs developers (and LLMs) love