Get Started
Here you will learn everything about implementing Accounda
into your website and processes. For more detailed information about our API and the authentication process, you can read our
documentation.
Here you can
download
a sample project (Flask).
To integrate Accounda as an authentication method, you need an app. Create your app here.
Once you've created an app, click on Authentication Data and save the CLIENT_ID and CLIENT_SECRET.
Install the latest version of our python package with pip.
pip install accounda
- The AUTH_ID (?auth_id) and AUTH_TOKEN (?token) will be passed as GET parameters after authentication.
- Use these parameters to verify the user's identity.
- To fetch additional user data (e.g., from google, microsoft, github, or discord), include the corresponding service in extra_params.
from accounda import AccoundaClient
client = AccoundaClient(client_id="PASTE CLIENT_ID HERE", client_secret="PASTE CLIENT_SECRET HERE")
valid, data = client.validate_user('PASTE AUTH_ID HERE', 'PASTE AUTH_TOKEN HERE', extra_params={"google": "1"})
If you only want to retrieve user information, without validating someone's authentication, you can use the following method. For additional data, add include the corresponding service (google, microsoft, github, discord) to extra_params.
data = client.get_user_information('PASTE AUTH_ID HERE', extra_params={"google": "1"})
This python package automatically handles access and refresh tokens and will refresh tokens once they are expired.
Now create a redirect URL in the app dashboard. Once the user has authorized your app on Accounda, they will be redirected to this URL. Then copy the link. (You can request access rights to Google, Microsoft, and others by first clicking on the respective icon and then copying the link.)
Then create a button in your app that redirects the user to this link:
<a class="accounda-oauth-btn" href="PASTE LINK HERE">
Sign in with
<img src="https://accounda.blob.core.windows.net/static/full-logo-darkmode.svg"
width="90px">
</a>
.accounda-oauth-btn {
display: block;
font-family: "Verdana", "Arial", "Tahoma", sans-serif;
max-width: 370px;
width: calc(100% - 8px);
font-size: 16px;
color: #fff;
text-align: center;
background-color: rgba(27, 28, 34, 0.9);
border: 1px solid rgba(88, 243, 151, 0.7);
padding: 12px 0;
border-radius: 8px;
font-weight: 570;
cursor: pointer;
text-decoration: none;
span {
margin-left: 2px;
}
}
Once the user has authorized your app, they will be redirected to your previously defined URL. Additionally, an AUTH_ID [ ?auth_id ] and an AUTH_TOKEN [ ?token ] will be passed as GET parameters. You can now access authorized data using the AUTH_ID. To uniquely authenticate a user, you need the AUTH_ID in combination with the AUTH_TOKEN.
To interact with the API, you first need an ACCESS_TOKEN. To obtain an ACCESS_TOKEN, you must authenticate with the API using your CLIENT_ID and CLIENT_SECRET.
import requests
url = 'https://api.accounda.com/v1/token/'
data = {
'client_id': 'PASTE CLIENT_ID HERE',
'client_secret': 'PASTE CLIENT_SECRET HERE'
}
response = requests.post(url, data=data)
access_token = response.json()['access_token']
In the third step, ensure that the user is correctly identified. To do this, use the AUTH_ID and AUTH_TOKEN that were transmitted after authorization. With this data, you can securely identify the user and verify that they are authorized to use the application.
url = 'https://api.accounda.com/v1/user/validate/?auth_id=PASTE AUTH_ID HERE'
headers = {
'Authorization': f'Bearer {access_token}',
'Content-Type': 'application/json',
'Client-ID': 'PASTE CLIENT_ID HERE',
'Auth-Token': 'PASTE AUTH_TOKEN HERE'
}
response = requests.get(url, headers=headers)
data = response.json()
if data.get('error'):
raise Exception(data['error'])
The above code snippet shows the simplest form of authentication. To also retrieve authorized data in the same request, you can use the corresponding parameters:
1: optional
, 8: required
Default Data: &user_data=1
*Google: &google=1
*Microsoft: µsoft=1
*Discord: &discord=1
*GitHub: &github=1
* Only possible in combination with &user_data=1
as a parameter.
You can find more detailed information on user authentication
here.
Access tokens are valid for 3600 seconds. To obtain a new access token without re-authenticating, you can use the refresh token provided alongside the access token. Each refresh token is valid for a single use and will either be invalidated immediately after use or expire after 7 days.
url = 'https://api.accounda.com/v1/token/refresh/'
headers = {
'Authorization': f'Bearer {refresh_token}',
'Content-Type': 'application/json',
'Client-ID': 'PASTE CLIENT_ID HERE'
}
response = requests.post(url, headers=headers)
access_token = response.json()['access_token']
Implement Accounda into your application quickly and benefit from numerous functions.
Create App