├── .gitignore ├── sample ├── app │ ├── .gitignore │ ├── src │ │ └── main │ │ │ ├── res │ │ │ ├── drawable-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values-sw600dp │ │ │ │ └── dimens.xml │ │ │ ├── values │ │ │ │ ├── dimens.xml │ │ │ │ ├── styles.xml │ │ │ │ └── strings.xml │ │ │ ├── values-sw720dp-land │ │ │ │ └── dimens.xml │ │ │ ├── values-v11 │ │ │ │ └── styles.xml │ │ │ ├── menu │ │ │ │ └── main.xml │ │ │ ├── values-v14 │ │ │ │ └── styles.xml │ │ │ └── layout │ │ │ │ ├── activity_main_old.xml │ │ │ │ └── activity_main.xml │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ └── com │ │ │ └── xiaomi │ │ │ └── account │ │ │ └── openauth │ │ │ └── demo │ │ │ └── ui │ │ │ ├── CustomizedAuthorizedActivity.java │ │ │ └── MainActivity.java │ ├── proguard-rules.pro │ └── build.gradle ├── settings.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── build.gradle ├── gradlew.bat └── gradlew ├── sdk ├── oauth.1.0.jar ├── oauth.1.1.jar ├── oauth.1.2.jar ├── oauth.1.3.jar ├── oauth.1.4.jar ├── oauth.1.5.jar ├── oauth.1.4.1.jar ├── oauth.1.4.2.jar ├── oauth.1.5.1.jar ├── oauth.1.5.2.jar ├── oauth.1.6.4.jar ├── oauth.1.6.5.jar ├── README.md ├── xiaomi-oauth.1.6.6.jar ├── xiaomi-oauth.1.6.7.jar └── xiaomi-oauth.1.6.8.jar ├── CHANGELOG.md └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /sample/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /sdk/oauth.1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sdk/oauth.1.0.jar -------------------------------------------------------------------------------- /sdk/oauth.1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sdk/oauth.1.1.jar -------------------------------------------------------------------------------- /sdk/oauth.1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sdk/oauth.1.2.jar -------------------------------------------------------------------------------- /sdk/oauth.1.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sdk/oauth.1.3.jar -------------------------------------------------------------------------------- /sdk/oauth.1.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sdk/oauth.1.4.jar -------------------------------------------------------------------------------- /sdk/oauth.1.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sdk/oauth.1.5.jar -------------------------------------------------------------------------------- /sdk/oauth.1.4.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sdk/oauth.1.4.1.jar -------------------------------------------------------------------------------- /sdk/oauth.1.4.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sdk/oauth.1.4.2.jar -------------------------------------------------------------------------------- /sdk/oauth.1.5.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sdk/oauth.1.5.1.jar -------------------------------------------------------------------------------- /sdk/oauth.1.5.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sdk/oauth.1.5.2.jar -------------------------------------------------------------------------------- /sdk/oauth.1.6.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sdk/oauth.1.6.4.jar -------------------------------------------------------------------------------- /sdk/oauth.1.6.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sdk/oauth.1.6.5.jar -------------------------------------------------------------------------------- /sdk/README.md: -------------------------------------------------------------------------------- 1 | 1.6.9以上版本请通过gradle的方式依赖: [查看release版本](https://github.com/xiaomi-passport/oauth-android-sdk/releases) -------------------------------------------------------------------------------- /sdk/xiaomi-oauth.1.6.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sdk/xiaomi-oauth.1.6.6.jar -------------------------------------------------------------------------------- /sdk/xiaomi-oauth.1.6.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sdk/xiaomi-oauth.1.6.7.jar -------------------------------------------------------------------------------- /sdk/xiaomi-oauth.1.6.8.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sdk/xiaomi-oauth.1.6.8.jar -------------------------------------------------------------------------------- /sample/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sample/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /sample/app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sample/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sample/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sample/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /sample/app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xiaomi-passport/oauth-android-sdk/HEAD/sample/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/app/src/main/res/values-sw600dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /sample/app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | 8 | -------------------------------------------------------------------------------- /sample/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip 7 | -------------------------------------------------------------------------------- /sample/app/src/main/res/values-sw720dp-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 128dp 8 | 9 | 10 | -------------------------------------------------------------------------------- /sample/app/src/main/res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /sample/app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 11 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /sample/app/src/main/res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /sample/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/qidu/Android/Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /sample/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /sample/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | maven { 7 | url 'https://maven.google.com/' 8 | name 'Google' 9 | } 10 | } 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:2.2.3' 13 | 14 | // NOTE: Do not place your application dependencies here; they belong 15 | // in the individual module build.gradle files 16 | } 17 | } 18 | 19 | allprojects { 20 | repositories { 21 | jcenter() 22 | maven { url 'https://raw.githubusercontent.com/xiaomi-passport/maven-repository/master/releases' } 23 | maven { 24 | url 'https://maven.google.com/' 25 | name 'Google' 26 | } 27 | } 28 | } 29 | 30 | task clean(type: Delete) { 31 | delete rootProject.buildDir 32 | } 33 | -------------------------------------------------------------------------------- /sample/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion "26.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.xiaomi.account.oauthdemo" 9 | minSdkVersion 14 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | 23 | dependencies { 24 | // compile fileTree(dir: '../../sdk', include: ['xiaomi-oauth.1.6.8.jar']) 25 | compile 'com.xiaomi.account:oauth-android:latest.release' 26 | // compile project(":library") 27 | // compile 'com.xiaomi.account:phoneNumKeep:0.4.4' 28 | compile 'com.android.support:appcompat-v7:26.1.0' 29 | 30 | testCompile 'junit:junit:4.12' 31 | } 32 | -------------------------------------------------------------------------------- /sample/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OpenAuthDemo 5 | Settings 6 | Hello world! 7 | 通过code获取accesstoken 8 | 通过refreshtoken获取accesstoken 9 | 测试签名 10 | 获取个人名片 11 | 获取好友列表 12 | 获取code 13 | 获取token 14 | HelperActivityForGetTokenUT 15 | 保存token等结果到SD卡 16 | 获取用户openId 17 | 获取用户电话号码 18 | 测试DeprecatedApi(不鼓励使用) 19 | 对话框 Oauth 20 | 21 | 22 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 1.7.1 2 | - 修复fastOAuth总是返回code, 即使使用accessToken 3 | 4 | # 1.7.0 5 | - 修复在三星手机上有时无法打开米家 6 | 7 | # 1.6.9 8 | - 支持通过米家进行oauth授权 9 | - 支持手机号自动填充 10 | - 支持通过gradle方式依赖 11 | 12 | # 1.6.8 13 | - 修复4.3上出现白屏的问题 14 | 15 | # 1.6.6 16 | - 支持通过miui9.5之后的系统帐号授权 17 | 18 | # 1.6.4 19 | - 支持小爱音箱水滴平台 20 | 21 | # 1.5.1 22 | - fix bugs 23 | 24 | # 1.5 25 | - fix Activity resource leak 26 | - add fastOAuth 27 | 28 | # 1.4.2 29 | - fix bug that AuthorizeActivity may crash if the deprecated "static" version of XiaomiOAuthorize#startGetAccessToken()/startGetOAuth() are called. This bug is instroduced in 1.2 version. 30 | 31 | # 1.4.1 32 | - fix vulnerability that AuthorizeActivity can be DDOS-attacked by passing unrecognized Serializable in Intent's extra. 33 | 34 | # 1.4 35 | - fix vulnerability that AuthorizeActivity can be DDOS-attacked by passing unrecognized Parceable in Intent's extra. 36 | 37 | # 1.3 38 | - fix bug that AuthorizeActivity crashes on MIUI V6.4 and above version, which is intruduced in 1.2 version. 39 | 40 | # 1.2 41 | - fix bug that oauth may fail if redirectUrl has upper-case letters, which is introduced in 1.1. 42 | - fix bug that NoTitleBar-themed AuthorizeActivity may crash if network error is met, which is introduced in 1.1. 43 | - add XiaomiOAuthorize#setCustomizedAuthorizeActivityClass. 44 | 45 | # 1.1 46 | - fix bug that can't register Mi Account by Gmail in OAuth webview. 47 | - add progress bar in OAuth webview Activity. 48 | - add refresh button in OAuth webview Activity. 49 | 50 | # 1.0 51 | Init version 52 | -------------------------------------------------------------------------------- /sample/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 23 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /sample/app/src/main/java/com/xiaomi/account/openauth/demo/ui/CustomizedAuthorizedActivity.java: -------------------------------------------------------------------------------- 1 | package com.xiaomi.account.openauth.demo.ui; 2 | 3 | import android.os.Bundle; 4 | import android.view.View; 5 | import android.webkit.WebView; 6 | import android.widget.Button; 7 | import android.widget.LinearLayout; 8 | import android.widget.LinearLayout.LayoutParams; 9 | import android.widget.ProgressBar; 10 | 11 | import com.xiaomi.account.openauth.AuthorizeActivityBase; 12 | 13 | public class CustomizedAuthorizedActivity extends AuthorizeActivityBase{ 14 | 15 | private ProgressBar mProgressBar; 16 | private Button mRefreshButton; 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | 22 | LinearLayout layout = new LinearLayout(this); 23 | layout.setOrientation(LinearLayout.VERTICAL); 24 | layout.setLayoutParams(new LayoutParams( 25 | LayoutParams.MATCH_PARENT, 26 | LayoutParams.MATCH_PARENT)); 27 | 28 | mProgressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal); 29 | layout.addView(mProgressBar, new LayoutParams( 30 | LayoutParams.MATCH_PARENT, 31 | LayoutParams.WRAP_CONTENT)); 32 | 33 | mRefreshButton = new Button(this); 34 | mRefreshButton.setText("click to refresh"); 35 | mRefreshButton.setOnClickListener(new View.OnClickListener() { 36 | @Override 37 | public void onClick(View v) { 38 | CustomizedAuthorizedActivity.this.refreshWebView(); 39 | } 40 | }); 41 | layout.addView(mRefreshButton); 42 | 43 | final WebView mWebView = super.getWebView(); 44 | layout.addView(mWebView, new LayoutParams( 45 | LayoutParams.MATCH_PARENT, 46 | LayoutParams.MATCH_PARENT)); 47 | 48 | setContentView(layout); 49 | } 50 | 51 | @Override 52 | protected void onShowProgress() { 53 | mProgressBar.setVisibility(View.VISIBLE); 54 | } 55 | 56 | @Override 57 | protected void onUpdateProgress(int newProgress) { 58 | mProgressBar.setProgress(newProgress); 59 | } 60 | 61 | @Override 62 | protected void onHideProgress() { 63 | mProgressBar.setVisibility(View.GONE); 64 | } 65 | 66 | @Override 67 | protected void onShowErrorUI() { 68 | mRefreshButton.setVisibility(View.VISIBLE); 69 | } 70 | 71 | @Override 72 | protected void onHideErrorUI() { 73 | mRefreshButton.setVisibility(View.GONE); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /sample/app/src/main/res/layout/activity_main_old.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 14 | 15 | 20 | 21 | 26 | 27 | 32 | 33 | 38 | 39 | 40 | 41 | 46 | 47 | 48 | 53 | 54 | 102 | 103 |