Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert changes from #654. Fix renew Credentials logic #670

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
* @return a request to start
*/
public fun renewAuth(refreshToken: String): Request<Credentials, AuthenticationException> {
val parameters = ParameterBuilder.newBuilderWithRequiredScope()
val parameters = ParameterBuilder.newBuilder()
.setClientId(clientId)
.setRefreshToken(refreshToken)
.setGrantType(ParameterBuilder.GRANT_TYPE_REFRESH_TOKEN)
Expand Down Expand Up @@ -690,7 +690,7 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
codeVerifier: String,
redirectUri: String
): Request<Credentials, AuthenticationException> {
val parameters = ParameterBuilder.newBuilderWithRequiredScope()
val parameters = ParameterBuilder.newBuilder()
.setClientId(clientId)
.setGrantType(ParameterBuilder.GRANT_TYPE_AUTHORIZATION_CODE)
.set(OAUTH_CODE_KEY, authorizationCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,6 @@ public class ParameterBuilder private constructor(parameters: Map<String, String
.setScope(OidcUtils.DEFAULT_SCOPE)
}

@JvmStatic
public fun newBuilderWithRequiredScope(): ParameterBuilder {
return newBuilder()
.setScope(OidcUtils.REQUIRED_SCOPE)
}

/**
* Creates a new instance of the builder.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.auth0.android.request.internal

import androidx.annotation.VisibleForTesting
import java.util.*

/**
Expand All @@ -9,7 +8,7 @@ import java.util.*
internal object OidcUtils {
internal const val KEY_SCOPE = "scope"
internal const val DEFAULT_SCOPE = "openid profile email"
internal const val REQUIRED_SCOPE = "openid"
private const val REQUIRED_SCOPE = "openid"

/**
* Given a string, it will check if it contains the scope of "openid".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.auth0.android.request.HttpMethod
import com.auth0.android.request.NetworkingClient
import com.auth0.android.request.RequestOptions
import com.auth0.android.request.ServerResponse
import com.auth0.android.request.internal.OidcUtils
import com.auth0.android.request.internal.RequestFactory
import com.auth0.android.request.internal.ThreadSwitcherShadow
import com.auth0.android.result.*
Expand Down Expand Up @@ -2201,7 +2200,7 @@ public class AuthenticationAPIClientTest {
)
assertThat(request.path, Matchers.equalTo("/oauth/token"))
val body = bodyFromRequest<String>(request)
assertThat(body, Matchers.hasEntry("scope", OidcUtils.REQUIRED_SCOPE))
assertThat(body, Matchers.not(Matchers.hasKey("scope")))
assertThat(body, Matchers.hasEntry("client_id", CLIENT_ID))
assertThat(body, Matchers.hasEntry("refresh_token", "refreshToken"))
assertThat(body, Matchers.hasEntry("grant_type", "refresh_token"))
Expand Down Expand Up @@ -2230,7 +2229,7 @@ public class AuthenticationAPIClientTest {
assertThat(body, Matchers.hasEntry("client_id", CLIENT_ID))
assertThat(body, Matchers.hasEntry("refresh_token", "refreshToken"))
assertThat(body, Matchers.hasEntry("grant_type", "refresh_token"))
assertThat(body, Matchers.hasEntry("scope", OidcUtils.REQUIRED_SCOPE))
assertThat(body, Matchers.not(Matchers.hasKey("scope")))
assertThat(credentials, Matchers.`is`(Matchers.notNullValue()))
}

Expand All @@ -2253,7 +2252,7 @@ public class AuthenticationAPIClientTest {
assertThat(body, Matchers.hasEntry("client_id", CLIENT_ID))
assertThat(body, Matchers.hasEntry("refresh_token", "refreshToken"))
assertThat(body, Matchers.hasEntry("grant_type", "refresh_token"))
assertThat(body, Matchers.hasEntry("scope", OidcUtils.REQUIRED_SCOPE))
assertThat(body, Matchers.not(Matchers.hasKey("scope")))
assertThat(credentials, Matchers.`is`(Matchers.notNullValue()))
}

Expand Down Expand Up @@ -2364,7 +2363,6 @@ public class AuthenticationAPIClientTest {
assertThat(body, Matchers.hasEntry("code", "code"))
assertThat(body, Matchers.hasEntry("code_verifier", "codeVerifier"))
assertThat(body, Matchers.hasEntry("redirect_uri", "http://redirect.uri"))
assertThat(body, Matchers.hasEntry("scope", OidcUtils.REQUIRED_SCOPE))
assertThat(
callback, AuthenticationCallbackMatcher.hasPayloadOfType(
Credentials::class.java
Expand All @@ -2390,7 +2388,6 @@ public class AuthenticationAPIClientTest {
assertThat(body, Matchers.hasEntry("code", "code"))
assertThat(body, Matchers.hasEntry("code_verifier", "codeVerifier"))
assertThat(body, Matchers.hasEntry("redirect_uri", "http://redirect.uri"))
assertThat(body, Matchers.hasEntry("scope", OidcUtils.REQUIRED_SCOPE))
assertThat(
callback, AuthenticationCallbackMatcher.hasError(
Credentials::class.java
Expand Down
Loading