3Speak Mobile App / dApps can integrate new Acela-Core to login
Hello 3Speak & Hive Community members,
With this post, I'll talk about new APIs which mobile app will be using.
I'll also explain how to use those API which can be used on any dApps.
And I'll also share all the links to those resources so that you can study & try it out on your own.
Link to documentation
- Here you can find the link to documentation - https://staging.3speak.tv/api/v1/docs
- As shown in the screenshot above, you can find all APIs details.
- Documentation covers every API request structure & response structure.
- At the end, you'll also find schemas with which you can get an understanding on necessary objects.
Acela-Core
- Acela-Core is a new Backend core for decentralised video applications on HIVE.
- It also supports logging in with social-accounts like twitter, github, gmail etc.
- In this post, I'll explain about how to login with Hive account.
- Other types of logins which are supported, I'll share more details as and when I get more familiar with.
- Acela-core repository can be found here - https://github.com/spknetwork/acela-core
Acela-Core - login with hive account
- Step 1. Create a payload which has account name & timestamp. Payload should look as follows.
{"account":"sagarkothari88","ts":"2024-01-29T16:15:24.515Z"}
Step 2. Get this payload signed with posting key. Now, in order to sign, either you can use posting key of user in case if you've access to it. In case of login via keychain, you can ask keychain to sign the payload for you.
Step 3. Once you've the proof of signed payload, you can compose a JSON object as follows.
{
"username": "sagarkothari88",
"network": "hive",
"authority_type": "posting",
"proof_payload": "{\"account\":\"sagarkothari88\",\"ts\":\"2024-01-29T16:15:24.515Z\"}",
"proof": "201134af9d7a90b858abcdefg52b6d6f9401532132484cef83f50fb633efd2e0e90240aa56c68bd1deba1eb4a510a261c94827f07d23497ac148aa0b1bedd919ea"
}
- Step 4. Send a post request to acela-core backend with above json object. Here is the cURL of the request.
curl 'https://acela.us-02.infra.3speak.tv/api/v1/auth/login_singleton' \
-H 'Accept: application/json, text/plain, */*' \
-H 'Content-Type: application/json' \
--data-raw '{"username":"sagarkothari88","network":"hive","authority_type":"posting","proof_payload":"{\"account\":\"sagarkothari88\",\"ts\":\"2024-01-29T16:15:24.515Z\"}","proof":"201134af9d7a90b858abcdefg52b6d6f9401532132484cef83f50fb633efd2e0e90240aa56c68bd1deba1eb4a510a261c94827f07d23497ac148aa0b1bedd919ea"}' \
--compressed
Here is the example response which you'll get.
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}
Congratulations. You're logged in. Now, you can use this JWT token for further requests.
Get proof via Keychain
- In order to get proof, you need to get it signed by the posting key.
- You can ask keychain to get it done for you
- https://github.com/hive-keychain/hive-keychain-extension/blob/master/documentation/README.md#requestsignbuffer
Get proof via posting key
- In case if you have user's posting key, you can use that to generate proof.
- Here is how you should do.
- Changes related to signing a message on
@hiveio/hivejswere merged 5 months ago
- Signing is simple with hivejs
const proof = hive.auth.signMessage(message, privateKey)
I wish you all the luck for integrating sign-in-with-hive-account using acela-core.
Let me know in the comment section if you find any difficulties.
Anyway, I'll keep up the good work on Hive. Thank you for checking my post.
Who am I?
- I'm a hive witness
- 3Speak App Developer
- Founder of HiveCurators Community -
@hive-185924
- I also contributed to mobile-app for HiveAuth
Support me
- Please upvote my content to motivate me.
- Do you like the work I do?
- Do you want me to keep going?
- Please Reblog
- Please help me connect with more communities
- Please vote me as Hive Witness
Vote me as Hive Witness
Leave 3Speak Mobile App / dApps can integrate new Acela-Core to login to:
Read more #hive-167922 posts
Best Posts From Sagar Kothari
More Posts From Sagar Kothari
- HiveSuite Dev Update: Hive Engine Portfolio Management & Smarter Governance Proposal Tracking
- HiveSuite Dev Update: Unified Wallet Tokens, New Welcome Experience & Full Blockchain Explorer
- HiveSuite Dev Update: Rich Activity Insights, Infinite Scroll Improvements & Sidebar Redesign.
- HiveSuite Dev Update: Governance Enhancements, Global Snaps Creation & Platform-Wide New Tab Support.
- HiveReactKit Dev Update: Enhanced Nav, Media Playback & Governance Improvements
- HiveSuite Game Update: Spider Solitaire Added to the Games Collection
- HiveSuite Dev Update: Klondike Solitaire Joins the Games Collection.
- HiveSuite Dev Update: Faster Navigation, Expanded Profile Drawer & Bookmark Experience Improvement.
- HiveSuite Dev Update: Shareable Profile Tabs & Redesigned Profile Drawer Experience
- HiveSuite Dev Update: Smart Mentions, Internal Navigation & Seamless Inline Media Experience.