Authenticate to link SmartPlayer's account
Important Reminder:
Before proceeding, ensure that you are authenticated and your Authorization has not expired.
Integration Guide:
SmartPlayer Sign-In manages the OAuth 2.0 and token lifecycle, simplifying your integration with SmartPlayer APIs.
This document describes how to complete a basic SmartPlayer Sign-In integration.
1. Add the Web Component
Place the following script inside your HTML Head Tag:
<script src="https://smartplayer.scaleup.com.br/script.js"></script>
2. Receive the Authorization token
After importing the script, invoke the WebComponent with the following arguments and function:
- authorization: Your generated Authorization.
- clientId: Integrator/App's ID.
- externalId: User's ID for validation/authentication.
- onEnable: Function to receive feedback for integration validation via the Login endpoint.
Example Integration Code:
<html>
<head>
<script src="https://smartplayer.scaleup.com.br/script.js"></script>
</head>
<body>
<smartplayer-oauth
authorization="MY_AUTH_CODE" //(1)
clientId="MY_ID" //(2)
externalId="[email protected]" //(3)
onEnable="(userInfo) => console.log('User info:', userInfo)"> //(4)
</smartplayer-oauth>
</body>
</html>
Upon successful execution, the button is disabled if the externalId is already validated and enabled.
Expected return from the fallback function:
User info:
{
authorizationCode: 'RETURNED_AUTH_CODE',
clientId: 'MY_ID',
externalId: '[email protected]',
}
3. Login endpoint:
After the user logs in and authorizes, the authorization_code field will be returned and ready for usage.
The cURL for login with grant_type=authorization_code :
curl --location 'https://services.scaleup.com.br/authentication/v1/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=CLIENT_ID' \
--data-urlencode 'client_secret=CLIENT_SECRET' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'code=RETURNED_AUTH_CODE' \
--data-urlencode 'redirect_uri=redirect_uri'
The login response will include a user session:
{
"user": {
"id": 3862,
"name": "name",
"code": "code",
"email": "email",
"phone": "phone",
"phoneExists": true,
"passwordUpdated": false
}
}
Important reminder:
Your role involves receiving the authorization token and internally authenticating and storing the keys.
By following these steps, you can effectively manage the authorization process and seamlessly integrate the web component. Get started today!
