Integrate HasCoding SSO Login into your website or application using account.hascoding.com.
- Go to account.hascoding.com
- Create an account
- and register your application with API management.
- Application Name
- Callback URL
- Once the application is created
- Client ID
- Client Secret
- Redirect URI
- Get these values.
HASCODING_CLIENT_ID=your-client-id
HASCODING_CLIENT_SECRET=your-client-secret
HASCODING_REDIRECT_URI=https://yourapp.com/callback
https://account.hascoding.com/authorize
?client_id=HASCODING_CLIENT_ID
&redirect_uri=HASCODING_REDIRECT_URI
&response_type=code
&scope=read // optional
&state=main // optional
Exchange the authorization code for an access token:
POST https://account.hascoding.com/token
Content-Type: application/json
{
"grant_type": "authorization_code",
"code": "AUTHORIZATION_CODE", // This value is what will be returned with the "code" parameter when you access your callback URL.
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET"
}
This process will return to you:
{
"access_token": "your_access_token",
"token_type": "Bearer",
"expires_in": 3600,
"id_token": "JWT Token",
"user_id": the logged-in user ID
}
When you open the JWT token with a parser, e.g. jwt.io You will see basic user information. This information includes:
preferred_username, email, email_verified, name, and picture.
For more user information, use userinfo.
Use the access token to get user profile data:
GET https://account.hascoding.com/userinfo
Authorization: Bearer ACCESS_TOKEN //The your_access_token value you received from the get token transaction
You will receive the following values as user information:
{
"sub": "1",
"preferred_username": "hascoding",
"phone_number": "9999999999",
"address": "user's address",
"name": "Hasan ERYILMAZ",
"krutbe": "The user's rank in the hascoding system, example: yonetici|uye",
"ksosyal": "hasaneryilmaz0||hasaneryilmaz0||hasan_eryilmaz_||hasaneryilmaz0||https://hasaneryilmaz.net", // User's social media usernames separated by "|" , facebook|twitter|instagram|youtube|website
"email": "hasaneryilmaz0@hascoding.com", // The virtual email address created by the user on hascoding is not a real email address.
"email_verified": true,
"picture": "https://account.hascoding.com/uploads/profile/7d8af5969068c4738dfabf831c1795ae.png",
"social": {
"facebook": "hasaneryilmaz0",
"twitter": "hasaneryilmaz0",
"instagram": "hasan_eryilmaz_",
"youtube": "hasaneryilmaz0",
"website": "https://hasaneryilmaz.net"
}
}
Your users can now log in to your site or app using their HasCoding account. You can look at ready-made example projects.