diff --git a/src/android/SpotifyOAuthPlugin.java b/src/android/SpotifyOAuthPlugin.java index 3480256..3e9b618 100644 --- a/src/android/SpotifyOAuthPlugin.java +++ b/src/android/SpotifyOAuthPlugin.java @@ -7,7 +7,9 @@ import org.apache.cordova.*; import org.json.*; -import com.spotify.sdk.android.authentication.*; +import com.spotify.sdk.android.auth.AuthorizationClient; +import com.spotify.sdk.android.auth.AuthorizationRequest; +import com.spotify.sdk.android.auth.AuthorizationResponse; public class SpotifyOAuthPlugin extends CordovaPlugin { private static final int LOGIN_REQUEST_CODE = 8139; @@ -16,7 +18,7 @@ public class SpotifyOAuthPlugin extends CordovaPlugin { private CallbackContext currentCtx = null; @Override - public boolean execute(String action, JSONArray args, CallbackContext ctx) + public boolean execute(String action, JSONArray args, CallbackContext ctx) throws JSONException { if ("getCode".equals(action)) { String clientId = args.getString(0); @@ -31,26 +33,26 @@ public boolean execute(String action, JSONArray args, CallbackContext ctx) } private void getCode( - final String clientId, - final String redirectUrl, + final String clientId, + final String redirectUrl, final String[] scopes, final CallbackContext ctx ) { cordova.setActivityResultCallback(this); this.currentCtx = ctx; - AuthenticationRequest ab = (new AuthenticationRequest.Builder( + AuthorizationRequest ab = (new AuthorizationRequest.Builder( clientId, - AuthenticationResponse.Type.CODE, + AuthorizationResponse.Type.CODE, redirectUrl )) .setScopes(scopes) .setShowDialog(true) .build(); - AuthenticationClient.openLoginActivity( - this.cordova.getActivity(), - LOGIN_REQUEST_CODE, + AuthorizationClient.openLoginActivity( + this.cordova.getActivity(), + LOGIN_REQUEST_CODE, ab ); } @@ -69,8 +71,8 @@ public void onActivityResult(int requestCode, int resultCode, Intent intent) { return; } - final AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, intent); - if (response.getType() == AuthenticationResponse.Type.CODE) { + final AuthorizationResponse response = AuthorizationClient.getResponse(resultCode, intent); + if (response.getType() == AuthorizationResponse.Type.CODE) { JSONObject res = new JSONObject(); try { res.put("code", response.getCode()); @@ -79,7 +81,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent intent) { } cb.success(res); } else { - JSONObject err = response.getType() == AuthenticationResponse.Type.EMPTY ? + JSONObject err = response.getType() == AuthorizationResponse.Type.EMPTY ? this.makeError( "auth_canceled", "The user cancelled the authentication process." @@ -89,7 +91,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent intent) { ); cb.error(err); } - + this.currentCtx = null; } @@ -116,4 +118,4 @@ private static String[] toStringArray(JSONArray arr) { } return res; } -} \ No newline at end of file +} diff --git a/src/android/build.gradle b/src/android/build.gradle index f9cdf1c..054612e 100644 --- a/src/android/build.gradle +++ b/src/android/build.gradle @@ -6,7 +6,7 @@ repositories { } dependencies { - compile 'com.spotify.android:auth:1.0.0-alpha' + implementation 'com.spotify.android:auth:1.2.3' } android { @@ -14,4 +14,4 @@ android { exclude 'META-INF/NOTICE' exclude 'META-INF/LICENSE' } -} \ No newline at end of file +} diff --git a/www/tsconfig.json b/www/tsconfig.json index bbfc040..235560f 100644 --- a/www/tsconfig.json +++ b/www/tsconfig.json @@ -12,6 +12,7 @@ "strictNullChecks": true, "suppressImplicitAnyIndexErrors": true, "noUnusedLocals": false, + "skipLibCheck": true, "experimentalDecorators": true }, "exclude": [