Double login (steem/hive) for website
I was doing some research few days ago, about the possibility to login both with steemlogin and hivesigner, on the same website, and I noticed there is no website that actually offer this service, or maybe I just miss it.
In any case I tried to develop a basic method to allow users to chose between steemlogin or hivesigner, to login.
To do so I used flask, so python language and the hivesigner package and the steemlogin I just forked from the first one.
Actually was quite easy and it worked quite fast.
So let's import the package for this:
from hivesigner.client import Client
from steemlogin.client import Client_sl [I changed it to differenciate from hivesigner Client]
import re
from flask import Flask, request, render_template,render_template_string, flash, redirect, url_for,send_from_directory,session
than declare the app name we set up before on both blockchains and create the objects for steem and hive:
client_id = "[app name]"
client_secret="[secret app key]"
ch = Client(client_id=client_id, client_secret=client_secret)
cs = Client_sl(client_id=client_id, client_secret=client_secret)
Than very esay, let's redirect the users to 2 different pages based on if they chose steem or hive login method:
@app.route('/steem')
def steem():
login_url_s = cs.get_login_url(
"http://localhost:5000/steem",
"login",
)
cs.access_token = request.args.get("access_token")
try:
login=cs.me()["name"]
link='#'
except Exception as e:
login="Log In"
link=login_url_s
return render_template('home_in.html',login=login,color="#0BA0DC",ac=ac_img,power='STEEM POWER')
####################################STEEM
########################################## HIVE
@app.route('/hive')
def hive():
login_url_h = ch.get_login_url(
"http://localhost:5000/hive",
"login",
)
ch.access_token = request.args.get("access_token")
try:
login=ch.me()["name"]
link='#'
except Exception as e:
login="Log In"
link=login_url_h
return render_template('home_in.html',login=login,color="#E71111",ac=ac_img,power='HIVE POWER')
With this very simple method you can have both steem and hive login with steemlogin and hivesigner on your website.
Leave Double login (steem/hive) for website to:
Read more #hive posts
Best Posts From the.journal
We have not curated any of the.journal's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From the.journal
- Restart the A.I. training
- Training new A.I. model
- New track from A.I. generated music
- Difference in output with 2 different A.I. scripts
- New Project- Artificial intelligence Music composer
- New curation trail no delegation required
- Double login (steem/hive) for website
- Python package for steemlogin.com
- How to encrypt information in custom_json [episode 2]
- How to encrypt information in custom_json [episode 1]