Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
2.6 kB
1
Indexable
Never
<script src="https://cdn.getphyllo.com/connect/v2/phyllo-connect.js"></script>

<script>
const config = {
  clientDisplayName: "PROJS", // the name of your app that you want the creators to see while granting access
  environment: "staging", // the mode in which you want to use the SDK,  'sandbox' or 'production'
  userId: "01f75be5-e32c-4183-b84b-c93e88888a3c", // the unique user_id parameter returned by Phyllo API when you create a user (see https://docs.getphyllo.com/docs/api-reference/reference/openapi.v1.yml/paths/~1v1~1users/post)
  token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMDFmNzViZTUtZTMyYy00MTgzLWI4NGItYzkzZTg4ODg4YTNjIiwidGVuYW50X2lkIjoiNGJiNDFlMjgtMGZmYy00N2NkLWE4YmUtY2I5ZGY0MmIzODA5IiwidGVuYW50X2FwcF9pZCI6IjIyOWU5YjAxLWZlMTItNGQyOC1iZmI2LWYxYmNiNGFiOGJhZSIsInByb2R1Y3RzIjpbIklERU5USVRZX0FVRElFTkNFIiwiSU5DT01FIiwiRU5HQUdFTUVOVCIsIklERU5USVRZIiwiRU5HQUdFTUVOVF9BVURJRU5DRSJdLCJpc3MiOiJodHRwczovL2FwaS5nZXRwaHlsbG8uY29tIiwiYXVkIjoiaHR0cHM6Ly9hcGkuZ2V0cGh5bGxvLmNvbS92MS9pbnRlcm5hbCIsImlhdCI6MTY5OTg2MjU2NC41Nzk3NywiZXhwIjoxNzAwNDY3MzY0LjU3OTc2NH0.aiCTiZ_EstYrhTVUtgXuhZzn5h9946Y8ETVGLiOo4pY"
};
    
const phylloConnect = PhylloConnect.initialize(config);
    
phylloConnect.on("accountConnected", (accountId, workplatformId, userId) => {  // gives the successfully connected account ID and work platform ID for the given user ID
  console.log(`onAccountConnected: ${accountId}, ${workplatformId}, ${userId}`);
})
phylloConnect.on("accountDisconnected", (accountId, workplatformId, userId) => {  // gives the successfully disconnected account ID and work platform ID for the given user ID
  console.log(`onAccountDisconnected: ${accountId}, ${workplatformId}, ${userId}`);
})
phylloConnect.on("tokenExpired", (userId) => {  // gives the user ID for which the token has expired
  console.log(`onTokenExpired: ${userId}`);  // the SDK closes automatically in case the token has expired, and you need to handle this by showing an appropriate UI and messaging to the users
})
phylloConnect.on("exit", (reason, userId) => {  // indicates that the user with given user ID has closed the SDK and gives an appropriate reason for it
  console.log(`onExit: ${reason}, ${userId}`);
})
phylloConnect.on("connectionFailure", (reason, workplatformId, userId) => {  // optional, indicates that the user with given user ID has attempted connecting to the work platform but resulted in a failure and gives an appropriate reason for it
  console.log(`onConnectionFailure: ${reason}, ${workplatformId}, ${userId}`);
})

your_button.onclick = phylloConnect.open();
</script>
Leave a Comment