本文整理汇总了Java中com.auth0.android.authentication.AuthenticationAPIClient类的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationAPIClient类的具体用法?Java AuthenticationAPIClient怎么用?Java AuthenticationAPIClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuthenticationAPIClient类属于com.auth0.android.authentication包,在下文中一共展示了AuthenticationAPIClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的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: validateToken
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的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
示例3: onAuthentication
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的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
示例4: onDatabaseAuthenticationRequest
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的package包/类
@SuppressWarnings("unused")
@Subscribe
public void onDatabaseAuthenticationRequest(DatabaseLoginEvent event) {
if (configuration.getDatabaseConnection() == null) {
Log.w(TAG, "There is no default Database connection to authenticate with");
return;
}
lockView.showProgress(true);
lastDatabaseLogin = event;
AuthenticationAPIClient apiClient = options.getAuthenticationAPIClient();
final HashMap<String, Object> parameters = new HashMap<>(options.getAuthenticationParameters());
if (event.getVerificationCode() != null) {
parameters.put(KEY_VERIFICATION_CODE, event.getVerificationCode());
}
final String connection = configuration.getDatabaseConnection().getName();
AuthenticationRequest request = apiClient.login(event.getUsernameOrEmail(), event.getPassword(), connection)
.addAuthenticationParameters(parameters);
if (options.getScope() != null) {
request.setScope(options.getScope());
}
if (options.getAudience() != null && options.getAccount().isOIDCConformant()) {
request.setAudience(options.getAudience());
}
request.start(authCallback);
}
开发者ID:auth0,项目名称:Lock.Android,代码行数:27,代码来源:LockActivity.java
示例5: shouldGetSignUpRequestWithUserMetadata
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的package包/类
@Test
public void shouldGetSignUpRequestWithUserMetadata() throws Exception {
AuthenticationAPIClient client = mock(AuthenticationAPIClient.class);
final Map<String, String> metadata = createMetadata();
ArgumentCaptor<Map> mapCaptor = ArgumentCaptor.forClass(Map.class);
SignUpRequest requestMock = mock(SignUpRequest.class);
Mockito.when(client.signUp(EMAIL, PASSWORD, CONNECTION)).thenReturn(requestMock);
DatabaseSignUpEvent event = new DatabaseSignUpEvent(EMAIL, PASSWORD, null);
event.setExtraFields(metadata);
event.getSignUpRequest(client, CONNECTION);
Mockito.verify(requestMock).addSignUpParameters(mapCaptor.capture());
assertValidMetadata(mapCaptor.getValue());
SignUpRequest usernameRequestMock = mock(SignUpRequest.class);
Mockito.when(client.signUp(EMAIL, PASSWORD, USERNAME, CONNECTION)).thenReturn(usernameRequestMock);
DatabaseSignUpEvent usernameEvent = new DatabaseSignUpEvent(EMAIL, PASSWORD, USERNAME);
usernameEvent.setExtraFields(metadata);
usernameEvent.getSignUpRequest(client, CONNECTION);
Mockito.verify(usernameRequestMock).addSignUpParameters(mapCaptor.capture());
assertValidMetadata(mapCaptor.getValue());
}
开发者ID:auth0,项目名称:Lock.Android,代码行数:23,代码来源:DatabaseSignUpEventTest.java
示例6: shouldGetCreateUserRequestWithUserMetadata
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的package包/类
@Test
public void shouldGetCreateUserRequestWithUserMetadata() throws Exception {
AuthenticationAPIClient client = mock(AuthenticationAPIClient.class);
final Map<String, String> metadata = createMetadata();
DatabaseConnectionRequest<DatabaseUser, AuthenticationException> requestMock = mock(DatabaseConnectionRequest.class);
Mockito.when(client.createUser(EMAIL, PASSWORD, CONNECTION)).thenReturn(requestMock);
DatabaseSignUpEvent event = new DatabaseSignUpEvent(EMAIL, PASSWORD, null);
event.setExtraFields(metadata);
event.getCreateUserRequest(client, CONNECTION);
Mockito.verify(requestMock).addParameter(KEY_USER_METADATA, metadata);
DatabaseConnectionRequest<DatabaseUser, AuthenticationException> usernameRequestMock = mock(DatabaseConnectionRequest.class);
Mockito.when(client.createUser(EMAIL, PASSWORD, USERNAME, CONNECTION)).thenReturn(usernameRequestMock);
DatabaseSignUpEvent eventUsername = new DatabaseSignUpEvent(EMAIL, PASSWORD, USERNAME);
eventUsername.setExtraFields(metadata);
eventUsername.getCreateUserRequest(client, CONNECTION);
Mockito.verify(usernameRequestMock).addParameter(KEY_USER_METADATA, metadata);
}
开发者ID:auth0,项目名称:Lock.Android,代码行数:20,代码来源:DatabaseSignUpEventTest.java
示例7: SecureCredentialsManager
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的package包/类
@VisibleForTesting
SecureCredentialsManager(@NonNull AuthenticationAPIClient apiClient, @NonNull Storage storage, @NonNull CryptoUtil crypto) {
this.apiClient = apiClient;
this.storage = storage;
this.crypto = crypto;
this.gson = GsonProvider.buildGson();
this.authenticateBeforeDecrypt = false;
}
开发者ID:auth0,项目名称:Auth0.Android,代码行数:9,代码来源:SecureCredentialsManager.java
示例8: PKCE
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的package包/类
@VisibleForTesting
PKCE(@NonNull AuthenticationAPIClient apiClient, @NonNull AlgorithmHelper algorithmHelper, @NonNull String redirectUri) {
this.apiClient = apiClient;
this.redirectUri = redirectUri;
this.codeVerifier = algorithmHelper.generateCodeVerifier();
this.codeChallenge = algorithmHelper.generateCodeChallenge(codeVerifier);
}
开发者ID:auth0,项目名称:Auth0.Android,代码行数:8,代码来源:PKCE.java
示例9: shouldCreateAManagerInstance
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的package包/类
@Test
public void shouldCreateAManagerInstance() throws Exception {
Context context = Robolectric.buildActivity(Activity.class).create().start().resume().get();
AuthenticationAPIClient apiClient = new AuthenticationAPIClient(new Auth0("clientId", "domain"));
Storage storage = new SharedPreferencesStorage(context);
final SecureCredentialsManager manager = new SecureCredentialsManager(context, apiClient, storage);
assertThat(manager, is(notNullValue()));
}
开发者ID:auth0,项目名称:Auth0.Android,代码行数:9,代码来源:SecureCredentialsManagerTest.java
示例10: requestNewIdToken
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的package包/类
/**
* Request for new IdToken using the refresh token
*/
private void requestNewIdToken() {
AuthenticationAPIClient client = new AuthenticationAPIClient(mAuth0);
client.delegationWithRefreshToken(mRefreshToken)
.start(new BaseCallback<Delegation, AuthenticationException>() {
@Override
public void onSuccess(Delegation payload) {
// retrieve the new id token and update the saved one
mIdToken = payload.getIdToken();
mPrefs.saveIdToken(mIdToken);
// try to validate the token again
validateToken();
}
@Override
public void onFailure(AuthenticationException error) {
// Something went wrong while requesting a new id token.
// This is likely to happen when the user has revoked access.
// We need to prompt them to login again.
Snackbar.make(mTextName,
R.string.error_access_revoked, Snackbar.LENGTH_INDEFINITE)
.setAction("Login", new View.OnClickListener() {
@Override
public void onClick(View view) {
clearCredentialsAndLogout();
}
})
.show();
}
});
}
开发者ID:segunfamisa,项目名称:auth0-demo-android,代码行数:35,代码来源:MainActivity.java
示例11: FacebookAuthProvider
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的package包/类
FacebookAuthProvider(String connectionName, AuthenticationAPIClient auth0, FacebookApi facebook) {
this.auth0 = auth0;
this.connectionName = connectionName;
this.facebook = facebook;
this.permissions = Collections.singleton("public_profile");
this.rememberLastLogin = true;
}
开发者ID:auth0,项目名称:Lock-Facebook.Android,代码行数:8,代码来源:FacebookAuthProvider.java
示例12: onCreate
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_photos);
FacebookAuthProvider provider = new FacebookAuthProvider(new AuthenticationAPIClient(getAccount()));
provider.rememberLastLogin(true);
provider.setPermissions(Arrays.asList("public_profile", "user_photos"));
lock = Lock.newBuilder(getAccount(), authCallback)
.withAuthHandlers(new FacebookAuthHandler(provider))
.allowedConnections(Collections.singletonList(FACEBOOK_CONNECTION))
.closable(true)
.build(this);
loginButton = (Button) findViewById(R.id.loginButton);
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(lock.newIntent(PhotosActivity.this));
}
});
progressBar = (ProgressBar) findViewById(R.id.progressBar);
photos = new ArrayList<>();
adapter = new PhotosAdapter(this, photos);
GridView gridView = (GridView) findViewById(R.id.grid);
gridView.setAdapter(adapter);
}
开发者ID:auth0,项目名称:Lock-Facebook.Android,代码行数:28,代码来源:PhotosActivity.java
示例13: createGoogleAuthProvider
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的package包/类
private GoogleAuthProvider createGoogleAuthProvider() {
GoogleAuthProvider provider = new GoogleAuthProvider(getString(R.string.google_server_client_id), new AuthenticationAPIClient(getAccount()));
provider.setScopes(new Scope(DriveScopes.DRIVE_METADATA_READONLY));
provider.setRequiredPermissions(new String[]{"android.permission.GET_ACCOUNTS"});
provider.rememberLastLogin(false);
return provider;
}
开发者ID:auth0,项目名称:Lock-Google.Android,代码行数:8,代码来源:FilesActivity.java
示例14: GoogleAuthProvider
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的package包/类
/**
* Creates Google Auth provider for a specific Google connection.
*
* @param connectionName of Auth0's connection used to Authenticate after user is authenticated with Google. Must be a Google connection
* @param serverClientId the OAuth 2.0 server client id obtained when creating a new credential on the Google API's console.
* @param client an Auth0 AuthenticationAPIClient instance
*/
public GoogleAuthProvider(@NonNull String connectionName, @NonNull String serverClientId, @NonNull AuthenticationAPIClient client) {
this.auth0 = client;
this.serverClientId = serverClientId;
this.scopes = new Scope[]{new Scope(Scopes.PLUS_LOGIN)};
this.connectionName = connectionName;
this.androidPermissions = new String[0];
this.rememberLastLogin = true;
}
开发者ID:auth0,项目名称:Lock-Google.Android,代码行数:16,代码来源:GoogleAuthProvider.java
示例15: onPasswordlessAuthenticationRequest
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的package包/类
@SuppressWarnings("unused")
@Subscribe
public void onPasswordlessAuthenticationRequest(PasswordlessLoginEvent event) {
if (configuration.getPasswordlessConnection() == null) {
Log.w(TAG, "There is no default Passwordless strategy to authenticate with");
return;
}
lockView.showProgress(true);
AuthenticationAPIClient apiClient = options.getAuthenticationAPIClient();
String connectionName = configuration.getPasswordlessConnection().getName();
if (event.getCode() != null) {
AuthenticationRequest request = event.getLoginRequest(apiClient, lastPasswordlessIdentity)
.addAuthenticationParameters(options.getAuthenticationParameters())
.setConnection(connectionName);
if (options.getScope() != null) {
request.setScope(options.getScope());
}
request.start(authCallback);
return;
}
lastPasswordlessIdentity = event.getEmailOrNumber();
lastPasswordlessCountry = event.getCountry();
event.getCodeRequest(apiClient, connectionName)
.start(passwordlessCodeCallback);
}
开发者ID:auth0,项目名称:Lock.Android,代码行数:28,代码来源:PasswordlessLockActivity.java
示例16: getCodeRequest
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的package包/类
/**
* Creates the ParameterizableRequest that will initiate the Passwordless Authentication flow.
*
* @param apiClient the API Client instance
* @param connectionName the name of the passwordless connection to request the login with. Only 'sms' and 'email' connections are allowed here.
* @return the Passwordless code request request.
*/
public ParameterizableRequest<Void, AuthenticationException> getCodeRequest(AuthenticationAPIClient apiClient, String connectionName) {
Log.d(TAG, String.format("Generating Passwordless Code/Link request for connection %s", connectionName));
ParameterizableRequest<Void, AuthenticationException> request;
if (getMode() == PasswordlessMode.EMAIL_CODE) {
request = apiClient.passwordlessWithEmail(getEmailOrNumber(), PasswordlessType.CODE);
} else if (getMode() == PasswordlessMode.EMAIL_LINK) {
request = apiClient.passwordlessWithEmail(getEmailOrNumber(), PasswordlessType.ANDROID_LINK);
} else if (getMode() == PasswordlessMode.SMS_CODE) {
request = apiClient.passwordlessWithSMS(getEmailOrNumber(), PasswordlessType.CODE);
} else {
request = apiClient.passwordlessWithSMS(getEmailOrNumber(), PasswordlessType.ANDROID_LINK);
}
return request.addParameter(KEY_CONNECTION, connectionName);
}
开发者ID:auth0,项目名称:Lock.Android,代码行数:22,代码来源:PasswordlessLoginEvent.java
示例17: getLoginRequest
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的package包/类
/**
* Creates the AuthenticationRequest that will finish the Passwordless Authentication flow.
*
* @param apiClient the API Client instance
* @param emailOrNumber the email or phone number used on the code request.
* @return the Passwordless login request.
*/
public AuthenticationRequest getLoginRequest(AuthenticationAPIClient apiClient, String emailOrNumber) {
Log.d(TAG, String.format("Generating Passwordless Login request for identity %s", emailOrNumber));
if (getMode() == PasswordlessMode.EMAIL_CODE || getMode() == PasswordlessMode.EMAIL_LINK) {
return apiClient.loginWithEmail(emailOrNumber, getCode());
} else {
return apiClient.loginWithPhoneNumber(emailOrNumber, getCode());
}
}
开发者ID:auth0,项目名称:Lock.Android,代码行数:16,代码来源:PasswordlessLoginEvent.java
示例18: getSignUpRequest
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的package包/类
public SignUpRequest getSignUpRequest(AuthenticationAPIClient apiClient, String connection) {
SignUpRequest request;
if (getUsername() != null) {
request = apiClient.signUp(getEmail(), getPassword(), getUsername(), connection);
} else {
request = apiClient.signUp(getEmail(), getPassword(), connection);
}
if (extraFields != null) {
Map<String, Object> params = new HashMap<>();
params.put(KEY_USER_METADATA, extraFields);
request.addSignUpParameters(params);
}
return request;
}
开发者ID:auth0,项目名称:Lock.Android,代码行数:15,代码来源:DatabaseSignUpEvent.java
示例19: getCreateUserRequest
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的package包/类
public DatabaseConnectionRequest<DatabaseUser, AuthenticationException> getCreateUserRequest(AuthenticationAPIClient apiClient, String connection) {
DatabaseConnectionRequest<DatabaseUser, AuthenticationException> request;
if (getUsername() != null) {
request = apiClient.createUser(getEmail(), getPassword(), getUsername(), connection);
} else {
request = apiClient.createUser(getEmail(), getPassword(), connection);
}
if (extraFields != null) {
request.addParameter(KEY_USER_METADATA, extraFields);
}
return request;
}
开发者ID:auth0,项目名称:Lock.Android,代码行数:13,代码来源:DatabaseSignUpEvent.java
示例20: shouldGetSignUpRequestWithUsername
import com.auth0.android.authentication.AuthenticationAPIClient; //导入依赖的package包/类
@Test
public void shouldGetSignUpRequestWithUsername() throws Exception {
AuthenticationAPIClient client = mock(AuthenticationAPIClient.class);
DatabaseSignUpEvent event = new DatabaseSignUpEvent(EMAIL, PASSWORD, USERNAME);
event.getSignUpRequest(client, CONNECTION);
Mockito.verify(client).signUp(EMAIL, PASSWORD, USERNAME, CONNECTION);
}
开发者ID:auth0,项目名称:Lock.Android,代码行数:9,代码来源:DatabaseSignUpEventTest.java
注:本文中的com.auth0.android.authentication.AuthenticationAPIClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论