PLYR GAMING UNIVERSE
  • API Endpoint
  • API Quickstart
  • API REFERENCE
    • Users
      • Authentication
        • PLYR[ID]
          • Login
          • Login and Approve
          • Logout
        • InstantPlayPass
          • RegisterIPP
          • RevealClaimingCode
          • VerifyClaimingCode
        • PLYR[CONNECT]
      • Check Session JWT
      • Get Basic User Info
      • Get Avatar
    • Game room
      • Create Game Room
      • Join Game Room
      • Pay Game Room
      • Earn Game Room
      • Leave Game Room
      • End Game Room
      • Helpers
        • Is Joined Game Room
        • Join and Pay
        • Earn and Leave
        • Create, Join and Pay
        • Earn, Leave and End
    • Assets
      • Tokens ( ERC-20 )
        • Get PLYR L1 Token List
        • Get User Token Balance
        • Get User Token Allowance
        • Approve User Token Spending
        • Revoke User Token Allowance
        • In-Game Chips
          • Create Chip
          • Mint Chip
          • Burn Chip
          • Transfer Chip
          • Get Chip Balance
          • Get Chip Info
      • NFTs ( ERC-721 )
        • Create NFT
        • Mint NFT
        • Transfer NFT
        • Burn NFT
        • Get NFT Balance
        • List NFTs
        • Check NFT Holding
        • Get NFT Credit
        • Get NFT Info
        • Get Zoo Genes
        • Official PLYR NFTs
          • Get User Zoo Genes
          • Get User Zoo Boosters
          • Get User Zoo Elixirs
      • Badge
        • Create Badge
        • Mint Badge
        • Remove Badge
        • Burn Badge
        • List Badges
        • Get Badge Info
    • Misc
      • Get Session JWT Public Key
      • Verify JWT Locally
      • Activity Logs
      • Get Task Message Status
Powered by GitBook
On this page
  • Endpoint of PLYR[CONNECT]
  • The required params to send to endpoint
  • The Action's requestData json structure
  • How to select Mode
  1. API REFERENCE
  2. Users
  3. Authentication

PLYR[CONNECT]

Last updated 16 days ago

UNDER DEVELOPMENT

The easiest way to authenticate users via Browser / In-App browser with various ways to give back authenticated data.

Endpoint of PLYR[CONNECT]

Mainnet :

Testnet:

The required params to send to endpoint

Example of Login

Parameter Name
Description
Remark

action

login approve loginAndApprove manageIPP

requestData

base64 encoded string of json.

Each action has itself json structure

The Action's requestData json structure

{
    "gameId": "tester",
    "expiresIn": "86400",
    "mode": "redirect",
    "callbackString": "callbackStringOfMyGame",
    "callbackUrl": "https://connect-testnet.plyr.network/test/"
}
{
    "gameId": "tester",
    "plyrId": "fennec2",
    "tokens": [
        "plyr",
        "gamr"
    ],
    "amounts": [
        "2222",
        "3333"
    ],
    "expiresIn": "86400",
    "mode": "redirect",
    "callbackString": "callbackStringOfMyGame",
    "callbackUrl": "https://connect-testnet.plyr.network/test/"
}
{
    "gameId": "tester",
    "tokens": [
      "plyr",
      "gamr"
    ],
    "amounts": [
      "4444",
      "5555"
      ],
    "expiresIn": "86400",
    "mode": "redirect",
    "callbackString": "callbackStringOfMyGame",
    "callbackUrl": "https://connect-testnet.plyr.network/test/"
}
{
    "gameId": "tester",
    "mode": "redirect",
    "callbackUrl": "https://connect-testnet.plyr.network/test/"
}

How to select Mode

Redirect

Open a new tab of browser. After authenticated, it will redirect to "callbackUrl".

If you want to do a polling interval to wait user to authenticate themself. you can do it by adding an extra param "uid" and pass the random UUID or any. and callbackUrl can be "/over" to show that authentication is successful

and you can use /auth/read/[uid] endpoint to check the result every interval you want. (recommended 2 - 5 seconds)

Callback

Opena new tab of browser. After authenticated, it will callback (Server side to callbackUrl)

Opener

You can do a popup browser window. It will use "window.opener.postMessage" to callback the origin / opener.

It will do a postMessage with the following structure

{ 
   "vendor": "plyrconnect",
   "action": "login", 
   "callbackString": "YouEnteredStringFromRequestData",
   "callbackData": "base64 encoded json data from PLYR API"
}   

After Authenticated you can addEventlistener('message') to capture the callbacked data

window.addEventListener('message', (e: any) => {
   if (e.data.vendor === 'plyrconnect') {
      console.log('callbackString:',e.data.callbackString)
      console.log('callbackData:', JSON.parse(atob(e.data.callbackData)))
   }
});

Iframe

You can do an iframe. It will use "window.parent.postMessage" to callback the parent.

It will do a postMessage with the following structure

{ 
   "vendor": "plyrconnect",
   "action": "login", 
   "callbackString": "YouEnteredStringFromRequestData",
   "callbackData": "base64 encoded json data from PLYR API"
}

After Authenticated you can addEventlistener('message') to capture the callbacked data

window.addEventListener('message', (e: any) => {
   if (e.data.vendor === 'plyrconnect') {
      console.log('callbackString:',e.data.callbackString)
      console.log('callbackData:', JSON.parse(atob(e.data.callbackData)))
   }
});
https://connect.plyr.network/
https://connect-testnet.plyr.network/
https://connect-testnet.plyr.network/?action=manageIPP&requestData=eyJnYW1lSWQiOiJ0ZXN0ZXIiLCJtb2RlIjoicmVkaXJlY3QiLCJjYWxsYmFja1VybCI6Imh0dHBzOi8vY29ubmVjdC10ZXN0bmV0LnBseXIubmV0d29yay90ZXN0LyJ9