Skip to content

Commit

Permalink
📝 集成华为
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyd-c committed Aug 5, 2019
1 parent 1ab1cc1 commit d5e161e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/main/java/me/zhyd/oauth/request/AuthHuaweiRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ private AuthUserGender getRealGender(JSONObject object) {
* @param object 接口返回的结果
*/
private void checkResponse(JSONObject object) {
if (object.containsKey("NSP_STATUS")) {
throw new AuthException(object.getString("error"));
}
if (object.containsKey("error")) {
if (!object.containsKey("sub_error") && !object.containsKey("error_description")) {
throw new AuthException(object.getString("error"));
}
throw new AuthException(object.getString("sub_error") + ":" + object.getString("error_description"));
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/me/zhyd/oauth/sdk/ThirdPartSdkTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public class ThirdPartSdkTest {

@Test
public void huawei() {
String code = "CF1IE8WDUI7HR0cTOcl59SHBmIo0EGugnY99HTnLjH0BiCu5+maSDDejA7V2FJntFGfdTXY/jD68WZAVW2cMZoXrHW0LHVQ+uYqb498PkdI453sejJcaSIS6bBCZJBNzrYKGk4PYWc5OS/yuPorSSNRlXXhjN9selraIOF+TBMb7wzXDho7FVz/Es2rInRfttnr3AEaIvkg=";
String code = "CF1IvwdXw18r6LTfoRSgs+LrdP/DuO1VJJmAD0up2grQrSs3gcuyrt1O+jjWp7/TFiBy9IlPepNs/PUggcLe8cgjesqj1+DGXXojJsjEqsokFCCU0eJVt1F02zLDWH1+bq40HSlljXDaTvCBNrqWJJnIZhRetoV9pocrWPLZpYrx/h0iaC9T0GjMRVEXC//LnTAlTjg7";
HttpResponse response = HttpRequest.post("https://oauth-login.cloud.huawei.com/oauth2/v2/token")
.form("grant_type", "authorization_code")
.form("code", code)
.form("client_id", "100994535")
.form("client_secret", "22aea400bef603fef26d15a79c806eb477b35de0a529758f2a3b1bda32bfb80d")
.form("client_id", "100xxxxx")
.form("client_secret", "22aea400bef603xxxxxbfb80d")
.form("redirect_uri", "http://localhost:8443/huawei/login")
.execute();
System.out.println(response.body());
Expand Down

0 comments on commit d5e161e

Please sign in to comment.