本文整理汇总了Java中com.auth0.android.provider.WebAuthProvider类的典型用法代码示例。如果您正苦于以下问题:Java WebAuthProvider类的具体用法?Java WebAuthProvider怎么用?Java WebAuthProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebAuthProvider类属于com.auth0.android.provider包,在下文中一共展示了WebAuthProvider类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.auth0.android.provider.WebAuthProvider; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
final Auth0 auth0 = new Auth0(this);
auth0.setOIDCConformant(true);
final Button loginButton = (Button) findViewById(R.id.loginButton);
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
WebAuthProvider.init(auth0)
.withScheme("demo")
.withScope("openid profile email")
.withAudience(String.format("https://%s/userinfo", getString(R.string.com_auth0_domain)))
.start(LoginActivity.this, callback);
}
});
}
示例2: login
import com.auth0.android.provider.WebAuthProvider; //导入依赖的package包/类
private void login() {
token.setText("Not logged in");
Auth0 auth0 = new Auth0(this);
auth0.setOIDCConformant(true);
WebAuthProvider.init(auth0)
.withScheme("demo")
.withAudience(String.format("https://%s/userinfo", getString(R.string.com_auth0_domain)))
.start(MainActivity.this, new AuthCallback() {
@Override
public void onFailure(@NonNull final Dialog dialog) {
runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.show();
}
});
}
@Override
public void onFailure(final AuthenticationException exception) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "Error: " + exception.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onSuccess(@NonNull final Credentials credentials) {
runOnUiThread(new Runnable() {
@Override
public void run() {
token.setText("Logged in: " + credentials.getAccessToken());
}
});
}
});
}
示例3: doLogin
import com.auth0.android.provider.WebAuthProvider; //导入依赖的package包/类
private void doLogin() {
WebAuthProvider.init(auth0)
.withScheme("demo")
.withScope("openid profile email")
.withAudience(String.format("https://%s/userinfo", getString(R.string.com_auth0_domain)))
.start(this, callback);
}
示例4: login
import com.auth0.android.provider.WebAuthProvider; //导入依赖的package包/类
private void login() {
Auth0 auth0 = new Auth0(this);
auth0.setOIDCConformant(true);
WebAuthProvider.init(auth0)
.withScheme("demo")
.withScope("openid email profile")
.withAudience(String.format("https://%s/userinfo", getString(R.string.com_auth0_domain)))
.start(LoginActivity.this, new AuthCallback() {
@Override
public void onFailure(@NonNull final Dialog dialog) {
runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.show();
}
});
}
@Override
public void onFailure(final AuthenticationException exception) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(LoginActivity.this, "Error: " + exception.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onSuccess(@NonNull final Credentials credentials) {
CredentialsManager.saveCredentials(LoginActivity.this, credentials);
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
});
}
示例5: doLogin
import com.auth0.android.provider.WebAuthProvider; //导入依赖的package包/类
private void doLogin() {
WebAuthProvider.init(auth0)
.withScheme("demo")
.withAudience(String.format("https://%s/userinfo", getString(R.string.com_auth0_domain)))
.withScope("openid offline_access")
.start(this, callback);
}
示例6: login
import com.auth0.android.provider.WebAuthProvider; //导入依赖的package包/类
private void login() {
Auth0 auth0 = new Auth0(this);
auth0.setOIDCConformant(true);
WebAuthProvider.init(auth0)
.withScheme("demo")
.withAudience(String.format("https://%s/userinfo", getString(R.string.com_auth0_domain)))
.start(LoginActivity.this, new AuthCallback() {
@Override
public void onFailure(@NonNull final Dialog dialog) {
runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.show();
}
});
}
@Override
public void onFailure(final AuthenticationException exception) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(LoginActivity.this, "Error: " + exception.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onSuccess(@NonNull final Credentials credentials) {
accessToken = credentials.getAccessToken();
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(LoginActivity.this, "Log in: Success", Toast.LENGTH_SHORT).show();
}
});
}
});
}
示例7: onNewIntent
import com.auth0.android.provider.WebAuthProvider; //导入依赖的package包/类
@Override
protected void onNewIntent(Intent intent) {
if (WebAuthProvider.resume(intent)) {
return;
}
super.onNewIntent(intent);
}
示例8: start
import com.auth0.android.provider.WebAuthProvider; //导入依赖的package包/类
/**
* Configures a new instance of the WebAuthProvider.Builder and starts it.
*
* @param activity a valid Activity context
* @param connection to use in the authentication
* @param extraAuthParameters extra authentication parameters to use along with the provided in the Options instance
* @param callback to deliver the authentication result to
* @param requestCode to use in the startActivityForResult request
*/
public void start(@NonNull Activity activity, @NonNull String connection, @Nullable Map<String, Object> extraAuthParameters, @NonNull AuthCallback callback, int requestCode) {
HashMap<String, Object> parameters;
if (extraAuthParameters == null) {
parameters = options.getAuthenticationParameters();
} else {
parameters = new HashMap<>(options.getAuthenticationParameters());
parameters.putAll(extraAuthParameters);
}
WebAuthProvider.Builder builder = WebAuthProvider.init(options.getAccount())
.useBrowser(options.useBrowser())
.withParameters(parameters)
.withConnection(connection);
final String connectionScope = options.getConnectionsScope().get(connection);
if (connectionScope != null) {
builder.withConnectionScope(connectionScope);
}
final String scope = options.getScope();
if (scope != null) {
builder.withScope(scope);
}
final String audience = options.getAudience();
if (audience != null && options.getAccount().isOIDCConformant()) {
builder.withAudience(audience);
}
final String scheme = options.getScheme();
if (scheme != null) {
builder.withScheme(scheme);
}
builder.start(activity, callback, requestCode);
}
示例9: onOAuthAuthenticationRequest
import com.auth0.android.provider.WebAuthProvider; //导入依赖的package包/类
@SuppressWarnings("unused")
@Subscribe
public void onOAuthAuthenticationRequest(OAuthLoginEvent event) {
lastPasswordlessIdentity = null;
lastPasswordlessCountry = null;
Log.v(TAG, "Looking for a provider to use with the connection " + event.getConnection());
currentProvider = AuthResolver.providerFor(event.getStrategy(), event.getConnection());
if (currentProvider != null) {
HashMap<String, Object> authParameters = new HashMap<>(options.getAuthenticationParameters());
final String connectionScope = options.getConnectionsScope().get(event.getConnection());
if (connectionScope != null) {
authParameters.put(Constants.CONNECTION_SCOPE_KEY, connectionScope);
}
final String scope = options.getScope();
if (scope != null) {
authParameters.put(ParameterBuilder.SCOPE_KEY, scope);
}
final String audience = options.getAudience();
if (audience != null && options.getAccount().isOIDCConformant()) {
authParameters.put(ParameterBuilder.AUDIENCE_KEY, audience);
}
currentProvider.setParameters(authParameters);
currentProvider.start(this, authProviderCallback, PERMISSION_REQUEST_CODE, CUSTOM_AUTH_REQUEST_CODE);
return;
}
Log.d(TAG, "Couldn't find an specific provider, using the default: " + WebAuthProvider.class.getSimpleName());
webProvider.start(this, event.getConnection(), null, authProviderCallback, WEB_AUTH_REQUEST_CODE);
}
示例10: login
import com.auth0.android.provider.WebAuthProvider; //导入依赖的package包/类
private void login() {
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);
final CredentialsManager credentialsManager = new CredentialsManager(authAPIClient, sharedPrefStorage);
WebAuthProvider.init(auth0)
.withScheme("demo")
.withAudience("https://api.exampleco.com/timesheets")
.withResponseType(ResponseType.CODE)
.withScope("create:timesheets read:timesheets openid profile email offline_access")
.start(LoginActivity.this, new AuthCallback() {
@Override
public void onFailure(@NonNull final Dialog dialog) {
runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.show();
}
});
}
@Override
public void onFailure(final AuthenticationException exception) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(LoginActivity.this, "Error: " + exception.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onSuccess(@NonNull final Credentials credentials) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(LoginActivity.this, "Log In - Success", Toast.LENGTH_SHORT).show();
}
});
credentialsManager.saveCredentials(credentials);
JWT jwt = new JWT(credentials.getIdToken());
String scopes = credentials.getScope();
User user = new User(
jwt.getClaim("email").asString(),
jwt.getClaim("name").asString(),
jwt.getClaim("picture").asString(),
credentials.getScope()
);
UserProfileManager.saveUserInfo(LoginActivity.this, user);
startActivity(new Intent(LoginActivity.this, TimeSheetActivity.class));
}
});
}
示例11: showWebAuth
import com.auth0.android.provider.WebAuthProvider; //导入依赖的package包/类
private void showWebAuth() {
WebAuthProvider.init(getAccount())
.withScheme("demo")
.withAudience(String.format("https://%s/userinfo", getString(R.string.com_auth0_domain)))
.start(this, webCallback);
}
示例12: onOAuthAuthenticationRequest
import com.auth0.android.provider.WebAuthProvider; //导入依赖的package包/类
@SuppressWarnings("unused")
@Subscribe
public void onOAuthAuthenticationRequest(OAuthLoginEvent event) {
final String connection = event.getConnection();
if (event.useActiveFlow()) {
lockView.showProgress(true);
Log.d(TAG, "Using the /ro endpoint for this OAuth Login Request");
AuthenticationRequest request = options.getAuthenticationAPIClient()
.login(event.getUsername(), event.getPassword(), connection)
.addAuthenticationParameters(options.getAuthenticationParameters());
if (options.getScope() != null) {
request.setScope(options.getScope());
}
if (options.getAudience() != null && options.getAccount().isOIDCConformant()) {
request.setAudience(options.getAudience());
}
request.start(authCallback);
return;
}
Log.v(TAG, "Looking for a provider to use /authorize with the connection " + connection);
currentProvider = AuthResolver.providerFor(event.getStrategy(), connection);
if (currentProvider != null) {
HashMap<String, Object> authParameters = new HashMap<>(options.getAuthenticationParameters());
final String connectionScope = options.getConnectionsScope().get(connection);
if (connectionScope != null) {
authParameters.put(Constants.CONNECTION_SCOPE_KEY, connectionScope);
}
final String scope = options.getScope();
if (scope != null) {
authParameters.put(ParameterBuilder.SCOPE_KEY, scope);
}
final String audience = options.getAudience();
if (audience != null && options.getAccount().isOIDCConformant()) {
authParameters.put(ParameterBuilder.AUDIENCE_KEY, audience);
}
if (!TextUtils.isEmpty(event.getUsername())) {
authParameters.put(KEY_LOGIN_HINT, event.getUsername());
}
currentProvider.setParameters(authParameters);
currentProvider.start(this, authProviderCallback, PERMISSION_REQUEST_CODE, CUSTOM_AUTH_REQUEST_CODE);
return;
}
Map<String, Object> extraAuthParameters = null;
if (!TextUtils.isEmpty(event.getUsername())) {
extraAuthParameters = Collections.singletonMap(KEY_LOGIN_HINT, (Object) event.getUsername());
}
Log.d(TAG, "Couldn't find an specific provider, using the default: " + WebAuthProvider.class.getSimpleName());
webProvider.start(this, connection, extraAuthParameters, authProviderCallback, WEB_AUTH_REQUEST_CODE);
}
示例13: resume
import com.auth0.android.provider.WebAuthProvider; //导入依赖的package包/类
/**
* Finishes the authentication flow in the WebAuthProvider
*
* @param intent the intent received in the onNewIntent method.
* @return true if a result was expected and has a valid format, or false if not
*/
public boolean resume(Intent intent) {
return WebAuthProvider.resume(intent);
}