Integrate Binance Login with your App
Binance Open SDK
Binance Open SDK (hereinafter called SDK) provides two authorization ways, through Binance ap or web page, which is convenient to authorize the Binance account safely and quickly. SDK will adopt different ways according to the situations and users' choices.
To begin, your app should identify the needed permissions (scope) firstly. Setup and register your app with Binance Accounts, and get your client_id . For now, Binance Login(Oauth2.0), is only provided to close ecosystem partners now. Please reach to our business team for more details.
Process Introduction
The Binance app will be called to authorize when the user clicks to login with the Binance account in the app. If the user does not install the Binance app supported the authorization,there would be a prompt for the user to authorize through the browser or download the Binance app. The result would be returned to the app after the authorization is finished.
Integrate SDK for Android
How to use?
Create a url
-
First you need a url start with 'https://accounts.binance.com/oauth/authorize' to construct an intent.
-
Add the query parameters listed on the
parameter and description
table(At the article's end). -
Eexample:
https://accounts.binance.com/oauth/authorize?response_type=code&scope=user:openId,create:apikey&client_id=xxxxxxxxx&redirect_uri=https%3A%2F%2Faccounts.pexpay.com%2Fen%2Foauth-handle&state=76ea8434ceca47ada566308030ef5f5c&bundleID=com.xxx.www
Create an Intent and start oauth activity
- Using the URL you created, to create an new Intent, then start the Activity:
Or
val uri = Uri.Builder()
.scheme("https")
.authority("accounts.binance.com")
.appendPath("oauth")
.appendPath("authorize")
.appendQueryParameter("response_type", "code")
.appendQueryParameter("scope", scope)
.appendQueryParameter("redirect_uri", redirectUri)
.appendQueryParameter("state", state)
.appendQueryParameter("client_id", clientID)
.build()
val intent = Intent(Intent.ACTION_VIEW, uri)
startActivity(intent)val uri = Uri.parse(
"https://accounts.binance.com/oauth/authorize?response_type=code&scope=user:openId,create:apikey&client_id=xxxxxxxxx&redirect_uri=https%3A%2F%2Faccounts.pexpay.com%2Fen%2Foauth-handle&state=76ea8434ceca47ada566308030ef5f5c&bundleID=com.xxx.www"
)
val intent = Intent(Intent.ACTION_VIEW, uri)
startActivity(intent)