Integrate Binance Login with your App
Binance Oauth 2.0
Binance Oauth 2.0 provides two authorization ways, through Binance app or web page, which is convenient to authorize the Binance account safely and quickly. it 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 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 descriptiontable(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)
Once user finish the oauth successfully, we will call the url you provided through redirect_uri
-
For example, if you pass "app://yourapp.com" as
redirect_uri -
Once user finish oauth.
- If success:
We will callapp://yourapp.com?code=xxxxx&state=xxxxxas intent uri with action:Intent.ACTION_VIEWand category:Intent.CATEGORY_BROWSABLE.
After getting the code, it will be sent to your server. Your server will then send it to the oauth server to get the user data and complete the authorization process. - If failed:
We will call
app://yourapp.com?error=xxxxx&error_description=xxxxxas intent uri with action:Intent.ACTION_VIEWand category:Intent.CATEGORY_BROWSABLE.
You can find the error and error_description on theerror and error_descriptiontable(At the article's end).
- If success:
-
So if you want to get the result of this OAuth action, you should announce that your app can consume the intent, you can achieve this by adding those codes into your AndroidMainfest.xml:
<activity
android:exported="true"
android:name=".YourActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="yourapp.com"
android:scheme="app" />
</intent-filter>
</activity>