File tree Expand file tree Collapse file tree
src/main/java/com/spotify/sdk/android/auth Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11Change Log
22==========
33
4+ ## Version 2.2.1
5+ - Resolve gradle check errors
6+
47## Version 2.2.0
58- Requesting token now uses PKCE when:
69 - There is an installed Spotify app that supports PKCE.
710 - When web fallback is used.
811
9-
1012## Version 2.1.2
1113* Propagate tracking parameters when opening the native login flow
1214
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ apply plugin: 'com.android.library'
2323
2424project. group = ' com.spotify.android'
2525project. archivesBaseName = ' auth'
26- project. version = ' 2.2.0 '
26+ project. version = ' 2.2.1 '
2727
2828android {
2929 compileSdk 33
@@ -87,6 +87,9 @@ android {
8787 unitTestVariants. configureEach {
8888 it. mergedFlavor. manifestPlaceholders + = manifestPlaceholdersForTests
8989 }
90+ testVariants. configureEach {
91+ it. mergedFlavor. manifestPlaceholders + = manifestPlaceholdersForTests
92+ }
9093}
9194
9295dependencies {
Original file line number Diff line number Diff line change 2525
2626import androidx .annotation .NonNull ;
2727
28- import java .nio .charset .StandardCharsets ;
2928import java .security .MessageDigest ;
3029import java .security .NoSuchAlgorithmException ;
3130import java .security .SecureRandom ;
@@ -57,9 +56,14 @@ private static String generateCodeVerifier() {
5756
5857 @ NonNull
5958 private static String generateCodeChallenge (@ NonNull String codeVerifier ) throws NoSuchAlgorithmException {
60- MessageDigest digest = MessageDigest .getInstance ("SHA-256" );
61- byte [] hash = digest .digest (codeVerifier .getBytes (StandardCharsets .US_ASCII ));
62- return Base64 .encodeToString (hash , Base64 .URL_SAFE | Base64 .NO_PADDING | Base64 .NO_WRAP );
59+ try {
60+ MessageDigest digest = MessageDigest .getInstance ("SHA-256" );
61+ byte [] hash = digest .digest (codeVerifier .getBytes ("US-ASCII" ));
62+ return Base64 .encodeToString (hash , Base64 .URL_SAFE | Base64 .NO_PADDING | Base64 .NO_WRAP );
63+ } catch (final java .io .UnsupportedEncodingException e ) {
64+ // US-ASCII is guaranteed to be supported on all platforms
65+ throw new RuntimeException ("US-ASCII encoding not supported" , e );
66+ }
6367 }
6468}
6569
Original file line number Diff line number Diff line change 3131import java .net .HttpURLConnection ;
3232import java .net .URL ;
3333import java .net .URLEncoder ;
34- import java .nio .charset .StandardCharsets ;
3534
3635/**
3736 * A utility class for exchanging an authorization code for an access token using PKCE verifier.
@@ -102,7 +101,12 @@ public TokenExchangeResponse execute() {
102101 final String requestBody = buildRequestBody ();
103102
104103 try (final OutputStream outputStream = connection .getOutputStream ()) {
105- outputStream .write (requestBody .getBytes (StandardCharsets .UTF_8 ));
104+ try {
105+ outputStream .write (requestBody .getBytes ("UTF-8" ));
106+ } catch (final java .io .UnsupportedEncodingException e ) {
107+ // UTF-8 is guaranteed to be supported on all platforms
108+ throw new RuntimeException ("UTF-8 encoding not supported" , e );
109+ }
106110 outputStream .flush ();
107111 }
108112
@@ -138,7 +142,7 @@ private String buildRequestBody() {
138142 private String readResponse (@ NonNull final HttpURLConnection connection , final boolean isError ) throws IOException {
139143 try (final BufferedReader reader = new BufferedReader (new InputStreamReader (
140144 isError ? connection .getErrorStream () : connection .getInputStream (),
141- StandardCharsets . UTF_8 ))) {
145+ "UTF-8" ))) {
142146
143147 final StringBuilder response = new StringBuilder ();
144148 String line ;
You can’t perform that action at this time.
0 commit comments