本文整理汇总了Java中com.auth0.android.callback.BaseCallback类的典型用法代码示例。如果您正苦于以下问题:Java BaseCallback类的具体用法?Java BaseCallback怎么用?Java BaseCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BaseCallback类属于com.auth0.android.callback包,在下文中一共展示了BaseCallback类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
});
}
开发者ID:auth0-samples,项目名称:auth0-pnp-exampleco-timesheets,代码行数:23,代码来源:BaseActivity.java
示例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();
}
});
}
});
}
开发者ID:auth0-samples,项目名称:auth0-android-sample,代码行数:24,代码来源:MainActivity.java
示例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();
}
});
}
开发者ID:auth0-samples,项目名称:auth0-android-sample,代码行数:26,代码来源:LoginActivity.java
示例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();
}
});
}
});
}
开发者ID:auth0-samples,项目名称:auth0-android-sample,代码行数:23,代码来源:MainActivity.java
示例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);
}
});
}
开发者ID:auth0,项目名称:Auth0.Android,代码行数:26,代码来源:PKCE.java
示例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));
}
开发者ID:auth0,项目名称:Auth0.Android,代码行数:26,代码来源:ProfileRequestTest.java
示例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);
}
开发者ID:auth0,项目名称:Auth0.Android,代码行数:18,代码来源:ProfileRequestTest.java
示例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);
}
开发者ID:auth0,项目名称:Auth0.Android,代码行数:18,代码来源:ProfileRequestTest.java
示例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();
}
});
}
开发者ID:segunfamisa,项目名称:auth0-demo-android,代码行数:25,代码来源:MainActivity.java
示例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) {
}
});
}
开发者ID:auth0,项目名称:Lock-Google.Android,代码行数:25,代码来源:FilesActivity.java
示例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"));
}
开发者ID:auth0,项目名称:Lock.Android,代码行数:23,代码来源:PasswordlessLockActivityTest.java
示例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"));
}
开发者ID:auth0,项目名称:Lock.Android,代码行数:23,代码来源:PasswordlessLockActivityTest.java
示例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"));
}
开发者ID:auth0,项目名称:Lock.Android,代码行数:20,代码来源:LockActivityTest.java
示例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"));
}
开发者ID:auth0,项目名称:Lock.Android,代码行数:22,代码来源:LockActivityTest.java
示例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"));
}
开发者ID:auth0,项目名称:Lock.Android,代码行数:22,代码来源:LockActivityTest.java
示例16: shouldCallLegacyDatabaseSignIn
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
@Test
public void shouldCallLegacyDatabaseSignIn() throws Exception {
when(configuration.loginAfterSignUp()).thenReturn(true);
DatabaseSignUpEvent event = new DatabaseSignUpEvent("email", "password", null);
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", "password", "connection");
verify(configuration, atLeastOnce()).getDatabaseConnection();
Map<String, String> reqParams = mapCaptor.getValue();
assertThat(reqParams, is(notNullValue()));
assertThat(reqParams, hasEntry("extra", "value"));
}
开发者ID:auth0,项目名称:Lock.Android,代码行数:22,代码来源:LockActivityTest.java
示例17: shouldCallEnterpriseOAuthAuthenticationWithActiveFlow
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
@Test
public void shouldCallEnterpriseOAuthAuthenticationWithActiveFlow() throws Exception {
OAuthConnection connection = mock(OAuthConnection.class);
when(connection.getName()).thenReturn("my-connection");
when(connection.isActiveFlowEnabled()).thenReturn(true);
OAuthLoginEvent event = new OAuthLoginEvent(connection, "[email protected]", "password");
activity.onOAuthAuthenticationRequest(event);
verify(lockView).showProgress(true);
verify(options).getAuthenticationAPIClient();
verify(authRequest).addAuthenticationParameters(mapCaptor.capture());
verify(authRequest).start(any(BaseCallback.class));
verify(authRequest).setScope("openid user photos");
verify(authRequest, never()).setAudience("aud");
verify(client).login("[email protected]", "password", "my-connection");
Map<String, String> reqParams = mapCaptor.getValue();
assertThat(reqParams, is(notNullValue()));
assertThat(reqParams, hasEntry("extra", "value"));
}
开发者ID:auth0,项目名称:Lock.Android,代码行数:22,代码来源:LockActivityTest.java
示例18: updateInformation
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
private void updateInformation(String countryUpdate) {
Map<String, Object> userMetadata = new HashMap<>();
userMetadata.put("country", countryUpdate);
final UsersAPIClient usersClient = new UsersAPIClient(auth0, CredentialsManager.getCredentials(MainActivity.this).getIdToken());
usersClient.updateMetadata(userProfile.getId(), userMetadata)
.start(new BaseCallback<UserProfile, ManagementException>() {
@Override
public void onSuccess(final UserProfile profile) {
userProfile = profile;
runOnUiThread(new Runnable() {
public void run() {
refreshScreenInformation();
}
});
}
@Override
public void onFailure(ManagementException error) {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(MainActivity.this, "Profile Update Failed", Toast.LENGTH_SHORT).show();
}
});
}
});
}
开发者ID:auth0-samples,项目名称:auth0-android-sample,代码行数:28,代码来源:MainActivity.java
示例19: BaseRequest
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
@VisibleForTesting
BaseRequest(HttpUrl url, OkHttpClient client, Gson gson, TypeAdapter<T> adapter, ErrorBuilder<U> errorBuilder, BaseCallback<T, U> callback, Map<String, String> headers, ParameterBuilder parameterBuilder) {
this.url = url;
this.client = client;
this.gson = gson;
this.adapter = adapter;
this.callback = callback;
this.headers = headers;
this.builder = parameterBuilder;
this.errorBuilder = errorBuilder;
}
开发者ID:auth0,项目名称:Auth0.Android,代码行数:12,代码来源:BaseRequest.java
示例20: start
import com.auth0.android.callback.BaseCallback; //导入依赖的package包/类
@Override
public void start(BaseCallback<T, U> callback) {
setCallback(callback);
try {
Request request = doBuildRequest();
client.newCall(request).enqueue(this);
} catch (RequestBodyBuildException e) {
final U exception = errorBuilder.from("Error parsing the request body", e);
callback.onFailure(exception);
}
}
开发者ID:auth0,项目名称:Auth0.Android,代码行数:12,代码来源:BaseRequest.java
注:本文中的com.auth0.android.callback.BaseCallback类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论