本文整理汇总了Java中com.auth0.android.callback.BaseCallback类的典型用法代码示例。如果您正苦于以下问题:Java BaseCallback类的具体用法?Java BaseCallback怎么用?Java BaseCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BaseCallback类属于com.auth0.android.callback包,在下文中一共展示了BaseCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Auth0 auth0 = new Auth0(getString(R.string.auth0_client_id), getString(R.string.auth0_domain));
auth0.setOIDCConformant(true);
AuthenticationAPIClient authAPIClient = new AuthenticationAPIClient(auth0);
SharedPreferencesStorage sharedPrefStorage = new SharedPreferencesStorage(this);
CredentialsManager credentialsManager = new CredentialsManager(authAPIClient, sharedPrefStorage);
credentialsManager.getCredentials(new BaseCallback<Credentials, CredentialsManagerException>() {
@Override
public void onSuccess(Credentials payload) {
mAccessToken = payload.getAccessToken();
}
@Override
public void onFailure(CredentialsManagerException error) {
Toast.makeText(BaseActivity.this, "Error: " + error.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
示例2: unlink
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
private void unlink(UserIdentity secondaryAccountIdentity) {
usersClient.unlink(userProfile.getId(), secondaryAccountIdentity.getId(), secondaryAccountIdentity.getProvider())
.start(new BaseCallback<List<UserIdentity>, ManagementException>() {
@Override
public void onSuccess(List<UserIdentity> payload) {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(MainActivity.this, "Account unlinked!", Toast.LENGTH_SHORT).show();
}
});
fetchFullProfile();
}
@Override
public void onFailure(final ManagementException error) {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(MainActivity.this, "Account unlink failed: " + error.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
});
}
示例3: performLink
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
private void performLink(String secondaryIdToken) {
UsersAPIClient client = new UsersAPIClient(auth0, CredentialsManager.getCredentials(LoginActivity.this).getIdToken());
client.link(primaryUserId, secondaryIdToken)
.start(new BaseCallback<List<UserIdentity>, ManagementException>() {
@Override
public void onSuccess(List<UserIdentity> payload) {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(LoginActivity.this, "Accounts linked!", Toast.LENGTH_SHORT).show();
}
});
finish();
}
@Override
public void onFailure(ManagementException error) {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(LoginActivity.this, "Account linking failed!", Toast.LENGTH_SHORT).show();
}
});
finish();
}
});
}
示例4: renewAuthentication
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
private void renewAuthentication() {
String refreshToken = CredentialsManager.getCredentials(this).getRefreshToken();
authenticationClient.renewAuth(refreshToken).start(new BaseCallback<Credentials, AuthenticationException>() {
@Override
public void onSuccess(final Credentials payload) {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(MainActivity.this, "New access_token: " + payload.getAccessToken(), Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onFailure(AuthenticationException error) {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(MainActivity.this, "Failed to get the new access_token", Toast.LENGTH_SHORT).show();
}
});
}
});
}
示例5: getToken
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
/**
* Performs a request to the Auth0 API to get the OAuth Token and end the PKCE flow.
* The instance of this class must be disposed after this method is called.
*
* @param authorizationCode received in the call to /authorize with a "grant_type=code"
* @param callback to notify the result of this call to.
*/
public void getToken(String authorizationCode, @NonNull final AuthCallback callback) {
apiClient.token(authorizationCode, redirectUri)
.setCodeVerifier(codeVerifier)
.start(new BaseCallback<Credentials, AuthenticationException>() {
@Override
public void onSuccess(Credentials payload) {
callback.onSuccess(payload);
}
@Override
public void onFailure(AuthenticationException error) {
if ("Unauthorized".equals(error.getDescription())) {
Log.e(TAG, "Please go to 'https://manage.auth0.com/#/applications/" + apiClient.getClientId() + "/settings' and set 'Client Type' to 'Native' to enable PKCE.");
}
callback.onFailure(error);
}
});
}
示例6: shouldReturnAuthenticationAfterStartingTheRequest
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
@Test
public void shouldReturnAuthenticationAfterStartingTheRequest() throws Exception {
final UserProfile userProfile = mock(UserProfile.class);
final Credentials credentials = mock(Credentials.class);
final AuthenticationRequestMock authenticationRequestMock = new AuthenticationRequestMock(credentials, null);
final ParameterizableRequestMock tokenInfoRequestMock = new ParameterizableRequestMock(userProfile, null);
final BaseCallback callback = mock(BaseCallback.class);
profileRequest = new ProfileRequest(authenticationRequestMock, tokenInfoRequestMock);
profileRequest.start(callback);
assertTrue(authenticationRequestMock.isStarted());
assertTrue(tokenInfoRequestMock.isStarted());
ArgumentCaptor<Authentication> authenticationCaptor = ArgumentCaptor.forClass(Authentication.class);
verify(callback).onSuccess(authenticationCaptor.capture());
assertThat(authenticationCaptor.getValue(), is(notNullValue()));
assertThat(authenticationCaptor.getValue(), is(instanceOf(Authentication.class)));
assertThat(authenticationCaptor.getValue().getCredentials(), is(notNullValue()));
assertThat(authenticationCaptor.getValue().getCredentials(), is(credentials));
assertThat(authenticationCaptor.getValue().getProfile(), is(notNullValue()));
assertThat(authenticationCaptor.getValue().getProfile(), is(userProfile));
}
示例7: shouldReturnErrorAfterStartingTheRequestIfAuthenticationRequestFails
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
@Test
public void shouldReturnErrorAfterStartingTheRequestIfAuthenticationRequestFails() throws Exception {
final UserProfile userProfile = mock(UserProfile.class);
final AuthenticationException error = mock(AuthenticationException.class);
final AuthenticationRequestMock authenticationRequestMock = new AuthenticationRequestMock(null, error);
final ParameterizableRequestMock tokenInfoRequestMock = new ParameterizableRequestMock(userProfile, null);
final BaseCallback callback = mock(BaseCallback.class);
profileRequest = new ProfileRequest(authenticationRequestMock, tokenInfoRequestMock);
profileRequest.start(callback);
assertTrue(authenticationRequestMock.isStarted());
assertFalse(tokenInfoRequestMock.isStarted());
verify(callback).onFailure(error);
}
示例8: shouldReturnErrorAfterStartingTheRequestIfTokenInfoRequestFails
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
@Test
public void shouldReturnErrorAfterStartingTheRequestIfTokenInfoRequestFails() throws Exception {
final Credentials credentials = mock(Credentials.class);
final AuthenticationException error = mock(AuthenticationException.class);
final AuthenticationRequestMock authenticationRequestMock = new AuthenticationRequestMock(credentials, null);
final ParameterizableRequestMock tokenInfoRequestMock = new ParameterizableRequestMock(null, error);
final BaseCallback callback = mock(BaseCallback.class);
profileRequest = new ProfileRequest(authenticationRequestMock, tokenInfoRequestMock);
profileRequest.start(callback);
assertTrue(authenticationRequestMock.isStarted());
assertTrue(tokenInfoRequestMock.isStarted());
verify(callback).onFailure(error);
}
示例9: validateToken
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
private void validateToken() {
AuthenticationAPIClient client = new AuthenticationAPIClient(mAuth0);
client.tokenInfo(mIdToken)
.start(new BaseCallback<UserProfile, AuthenticationException>() {
@Override
public void onSuccess(final UserProfile payload) {
Log.d(TAG, payload.getExtraInfo().toString());
MainActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
// update ui
updateUI(payload);
}
});
}
@Override
public void onFailure(AuthenticationException error) {
// this means that the id token has expired.
// We need to request for a new one, using the refresh token
requestNewIdToken();
}
});
}
示例10: onAuthentication
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
@Override
public void onAuthentication(Credentials credentials) {
Log.i(TAG, "Auth ok! User has given us all google requested permissions.");
AuthenticationAPIClient client = new AuthenticationAPIClient(getAccount());
client.tokenInfo(credentials.getIdToken())
.start(new BaseCallback<UserProfile, AuthenticationException>() {
@Override
public void onSuccess(UserProfile payload) {
final GoogleAccountCredential credential = GoogleAccountCredential.usingOAuth2(FilesActivity.this, Collections.singletonList(DriveScopes.DRIVE_METADATA_READONLY));
credential.setSelectedAccountName(payload.getEmail());
runOnUiThread(new Runnable() {
@Override
public void run() {
new FetchFilesTask().execute(credential);
}
});
}
@Override
public void onFailure(AuthenticationException error) {
}
});
}
示例11: shouldDoPasswordlessLoginWithEmail
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
@Test
public void shouldDoPasswordlessLoginWithEmail() throws Exception {
activity = new PasswordlessLockActivity(configuration, options, lockView, webProvider, "[email protected]");
PasswordlessLoginEvent event = PasswordlessLoginEvent.submitCode(PasswordlessMode.EMAIL_CODE, "1234");
activity.onPasswordlessAuthenticationRequest(event);
ArgumentCaptor<Map> mapCaptor = ArgumentCaptor.forClass(Map.class);
verify(lockView).showProgress(true);
verify(options).getAuthenticationAPIClient();
verify(client).loginWithEmail(eq("[email protected]"), eq("1234"));
verify(authRequest).addAuthenticationParameters(mapCaptor.capture());
verify(authRequest).setConnection(eq("connection"));
verify(authRequest).setScope("openid user photos");
verify(authRequest).start(any(BaseCallback.class));
verify(configuration, atLeastOnce()).getPasswordlessConnection();
Map<String, String> reqParams = mapCaptor.getValue();
assertThat(reqParams, is(notNullValue()));
assertThat(reqParams, hasEntry("extra", "value"));
}
示例12: shouldDoPasswordlessLoginWithPhone
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
@Test
public void shouldDoPasswordlessLoginWithPhone() throws Exception {
activity = new PasswordlessLockActivity(configuration, options, lockView, webProvider, "+541234567890");
PasswordlessLoginEvent event = PasswordlessLoginEvent.submitCode(PasswordlessMode.SMS_CODE, "1234");
activity.onPasswordlessAuthenticationRequest(event);
ArgumentCaptor<Map> mapCaptor = ArgumentCaptor.forClass(Map.class);
verify(lockView).showProgress(true);
verify(options).getAuthenticationAPIClient();
verify(client).loginWithPhoneNumber(eq("+541234567890"), eq("1234"));
verify(authRequest).addAuthenticationParameters(mapCaptor.capture());
verify(authRequest).setConnection(eq("connection"));
verify(authRequest).setScope("openid user photos");
verify(authRequest).start(any(BaseCallback.class));
verify(configuration, atLeastOnce()).getPasswordlessConnection();
Map<String, String> reqParams = mapCaptor.getValue();
assertThat(reqParams, is(notNullValue()));
assertThat(reqParams, hasEntry("extra", "value"));
}
示例13: shouldCallLegacyDatabaseLogin
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
@Test
public void shouldCallLegacyDatabaseLogin() throws Exception {
DatabaseLoginEvent event = new DatabaseLoginEvent("username", "password");
activity.onDatabaseAuthenticationRequest(event);
verify(lockView).showProgress(true);
verify(options).getAuthenticationAPIClient();
verify(client).login("username", "password", "connection");
verify(authRequest).addAuthenticationParameters(mapCaptor.capture());
verify(authRequest).start(any(BaseCallback.class));
verify(authRequest).setScope("openid user photos");
verify(authRequest, never()).setAudience("aud");
verify(configuration, atLeastOnce()).getDatabaseConnection();
Map<String, String> reqParams = mapCaptor.getValue();
assertThat(reqParams, is(notNullValue()));
assertThat(reqParams, hasEntry("extra", "value"));
}
示例14: shouldCallLegacyDatabaseLoginWithVerificationCode
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
@Test
public void shouldCallLegacyDatabaseLoginWithVerificationCode() throws Exception {
DatabaseLoginEvent event = new DatabaseLoginEvent("username", "password");
event.setVerificationCode("123456");
activity.onDatabaseAuthenticationRequest(event);
verify(lockView).showProgress(true);
verify(options).getAuthenticationAPIClient();
verify(client).login("username", "password", "connection");
verify(authRequest).addAuthenticationParameters(mapCaptor.capture());
verify(authRequest).start(any(BaseCallback.class));
verify(authRequest).setScope("openid user photos");
verify(authRequest, never()).setAudience("aud");
verify(configuration, atLeastOnce()).getDatabaseConnection();
Map<String, String> reqParams = mapCaptor.getValue();
assertThat(reqParams, is(notNullValue()));
assertThat(reqParams, hasEntry("extra", "value"));
assertThat(reqParams, hasEntry("mfa_code", "123456"));
}
示例15: shouldCallLegacyDatabaseSignInWithUsername
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
@Test
public void shouldCallLegacyDatabaseSignInWithUsername() throws Exception {
when(configuration.loginAfterSignUp()).thenReturn(true);
DatabaseSignUpEvent event = new DatabaseSignUpEvent("[email protected]", "password", "username");
activity.onDatabaseAuthenticationRequest(event);
verify(lockView).showProgress(true);
verify(options).getAuthenticationAPIClient();
verify(signUpRequest).addAuthenticationParameters(mapCaptor.capture());
verify(signUpRequest).start(any(BaseCallback.class));
verify(signUpRequest).setScope("openid user photos");
verify(signUpRequest, never()).setAudience("aud");
verify(client).signUp("[email protected]", "password", "username", "connection");
verify(configuration, atLeastOnce()).getDatabaseConnection();
Map<String, String> reqParams = mapCaptor.getValue();
assertThat(reqParams, is(notNullValue()));
assertThat(reqParams, hasEntry("extra", "value"));
}