• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CredentialRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.android.gms.auth.api.credentials.CredentialRequest的典型用法代码示例。如果您正苦于以下问题:Java CredentialRequest类的具体用法?Java CredentialRequest怎么用?Java CredentialRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CredentialRequest类属于com.google.android.gms.auth.api.credentials包,在下文中一共展示了CredentialRequest类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getCredentials

import com.google.android.gms.auth.api.credentials.CredentialRequest; //导入依赖的package包/类
/**
 * Begin the process of retrieving a {@link Credential} for the device user. This can have
 * a few different results:
 *   1) If the user has auto sign-in enabled and exactly one previously saved credential,
 *      {@link SmartLockListener#onCredentialRetrieved(Credential)} will be called and
 *      you can sign the user in immediately.
 *   2) If the user has multiple saved credentials or one saved credential and has disabled
 *      auto sign-in, you will get the callback {@link SmartLockListener#onShouldShowCredentialPicker()}
 *      at which point you can choose to show the picker dialog to continue.
 *   3) If the user has no saved credentials or cancels the operation, you will receive the
 *      {@link SmartLockListener#onCredentialRetrievalFailed()} callback.
 */
public void getCredentials() {
    CredentialRequest request = buildCredentialRequest();

    Auth.CredentialsApi.request(getFragment().getGoogleApiClient(), request)
            .setResultCallback(new ResultCallback<CredentialRequestResult>() {
                @Override
                public void onResult(CredentialRequestResult result) {
                    if (result.getStatus().isSuccess()) {
                        // Single credential, auto sign-in
                        Credential credential = result.getCredential();
                        getListener().onCredentialRetrieved(credential);
                    } else if (result.getStatus().hasResolution() &&
                            result.getStatus().getStatusCode() != CommonStatusCodes.SIGN_IN_REQUIRED) {
                        // Multiple credentials or auto-sign in disabled.  If the status
                        // code is SIGN_IN_REQUIRED then it is a hint credential, which we
                        // do not want at this point.
                        getListener().onShouldShowCredentialPicker();
                    } else {
                        // Could not retrieve credentials
                        getListener().onCredentialRetrievalFailed();
                    }
                }
            });
}
 
开发者ID:googlearchive,项目名称:easygoogle,代码行数:37,代码来源:SmartLock.java


示例2: showCredentialPicker

import com.google.android.gms.auth.api.credentials.CredentialRequest; //导入依赖的package包/类
/**
 * Show the dialog allowing the user to choose a Credential. This method shoud only be called
 * after you receive the {@link SmartLockListener#onShouldShowCredentialPicker()} callback.
 */
public void showCredentialPicker() {
    CredentialRequest request = buildCredentialRequest();
    Activity activity = getFragment().getActivity();
    int maskedCode = getFragment().maskRequestCode(RC_READ);

    Auth.CredentialsApi.request(getFragment().getGoogleApiClient(), request)
            .setResultCallback(new ResolvingResultCallbacks<CredentialRequestResult>(activity, maskedCode) {
                @Override
                public void onSuccess(CredentialRequestResult result) {
                    getListener().onCredentialRetrieved(result.getCredential());
                }

                @Override
                public void onUnresolvableFailure(Status status) {
                    Log.e(TAG, "showCredentialPicker:onUnresolvableFailure:" + status);
                }
            });
}
 
开发者ID:googlearchive,项目名称:easygoogle,代码行数:23,代码来源:SmartLock.java


示例3: buildCredentialRequest

import com.google.android.gms.auth.api.credentials.CredentialRequest; //导入依赖的package包/类
private CredentialRequest buildCredentialRequest() {
    return new CredentialRequest.Builder()
            .setCredentialPickerConfig(new CredentialPickerConfig.Builder()
                .setShowAddAccountButton(false)
                .setShowCancelButton(true)
                .setForNewAccount(false)
                .build())
            .setPasswordLoginSupported(true)
            .build();
}
 
开发者ID:googlearchive,项目名称:easygoogle,代码行数:11,代码来源:SmartLock.java


示例4: onCreate

import com.google.android.gms.auth.api.credentials.CredentialRequest; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstance) {
    super.onCreate(savedInstance);
    if (savedInstance != null) {
        // We already have a running instance of this fragment
        return;
    }

    FlowParameters flowParams = getFlowParams();
    if (flowParams.enableCredentials) {
        getDialogHolder().showLoadingDialog(R.string.fui_progress_dialog_loading);

        mGoogleApiClient = new GoogleApiClient.Builder(getContext().getApplicationContext())
                .addConnectionCallbacks(this)
                .addApi(Auth.CREDENTIALS_API)
                .enableAutoManage(getActivity(), GoogleApiHelper.getSafeAutoManageId(), this)
                .build();
        mGoogleApiClient.connect();

        getAuthHelper().getCredentialsApi()
                .request(mGoogleApiClient,
                        new CredentialRequest.Builder()
                                .setPasswordLoginSupported(true)
                                .setAccountTypes(getSupportedAccountTypes().toArray(new String[0]))
                                .build())
                .setResultCallback(this);
    } else {
        startAuthMethodChoice();
    }
}
 
开发者ID:firebase,项目名称:FirebaseUI-Android,代码行数:31,代码来源:SignInDelegate.java


示例5: shouldClearItselfOnStop

import com.google.android.gms.auth.api.credentials.CredentialRequest; //导入依赖的package包/类
@Test
public void shouldClearItselfOnStop() throws Exception {
    doCallRealMethod().when(smartLock).startTask(eq(task));
    smartLock.setCallback(callback);
    smartLock.startTask(task);
    smartLock.onStop();
    assertThat(smartLock.credentialRequest, is(nullValue(CredentialRequest.class)));
    assertThat(smartLock.currentTask(), is(nullValue(GoogleApiClientConnectTask.class)));
    assertThat(smartLock.getCallback(), notNullValue(CredentialStoreCallback.class));
    verifyCallbackIsCleaned();
    verify(task).cancel(false);
    verify(googleApiClient).disconnect();
}
 
开发者ID:auth0,项目名称:Lock-SmartLock,代码行数:14,代码来源:SmartLockTest.java


示例6: attemptRequestCredentials

import com.google.android.gms.auth.api.credentials.CredentialRequest; //导入依赖的package包/类
/**
 * Request option 1: https://developers.google.com/identity/smartlock-passwords/android/overview
 */
private void attemptRequestCredentials() {
    if (mIsResolving) {
        return;
    }

    mNeedToRequestCredentials = true;
    mLoginButton.setText(getString(R.string.retrieving_credentials));

    CredentialRequest request = new CredentialRequest.Builder()
            .setSupportsPasswordLogin(true)
            .build();

    if (mGoogleApiClient.isConnected()) {
        Auth.CredentialsApi.request(mGoogleApiClient, request).setResultCallback(
                credentialRequestResult -> {
                    finishAllLoading();
                    final Status status = credentialRequestResult.getStatus();
                    if (status.isSuccess()) {
                        // Single credential and auto sign-in enabled.
                        //Request 2
                        processRetrievedCredential(credentialRequestResult.getCredential(), false);
                    } else if (status.getStatusCode() == CommonStatusCodes.RESOLUTION_REQUIRED) {
                        // Multiple credentials - pick one
                        //Request 3
                        resolveResult(status, RC_READ);
                    } else if (status.getStatusCode() == CommonStatusCodes.SIGN_IN_REQUIRED) {
                        loadHints();
                    }
                });
        mNeedToRequestCredentials = false;
    }
}
 
开发者ID:mvhs-apps,项目名称:mvhs-app,代码行数:36,代码来源:AeriesFragment.java


示例7: setCredentialRequest

import com.google.android.gms.auth.api.credentials.CredentialRequest; //导入依赖的package包/类
public void setCredentialRequest(CredentialRequest credentialRequest) {
    mCredentialRequest = credentialRequest;
}
 
开发者ID:pchmn,项目名称:RxSocialAuth,代码行数:4,代码来源:RxSmartLockPasswordsFragment.java


示例8: Builder

import com.google.android.gms.auth.api.credentials.CredentialRequest; //导入依赖的package包/类
public Builder(FragmentActivity activity) {
    this.activity = activity;
    credentialRequestBuilder = new CredentialRequest.Builder();
    // at least one provider (mandatory)
    credentialRequestBuilder.setAccountTypes(IdentityProviders.GOOGLE);
}
 
开发者ID:pchmn,项目名称:RxSocialAuth,代码行数:7,代码来源:RxSmartLockPasswords.java


示例9: requestCredentials

import com.google.android.gms.auth.api.credentials.CredentialRequest; //导入依赖的package包/类
private void requestCredentials() {
        mSignInButton.setEnabled(false);
        mIsRequesting = true;

        CredentialRequest request = new CredentialRequest.Builder()
                .setPasswordLoginSupported(true)
                .setAccountTypes(IdentityProviders.GOOGLE, IdentityProviders.TWITTER)
                .build();

        Auth.CredentialsApi.request(mGoogleApiClient, request).setResultCallback(
                new ResultCallback<CredentialRequestResult>() {
                    @Override
                    public void onResult(CredentialRequestResult credentialRequestResult) {
//                        mIsRequesting = false;
                        Status status = credentialRequestResult.getStatus();
                        if (credentialRequestResult.getStatus().isSuccess()) {
                            // Successfully read the credential without any user interaction, this
                            // means there was only a single credential and the user has auto
                            // sign-in enabled.
                            Credential credential = credentialRequestResult.getCredential();
                            processRetrievedCredential(credential);
                        } else if (status.getStatusCode() == CommonStatusCodes.RESOLUTION_REQUIRED) {
//                            setFragment(null);
                            // This is most likely the case where the user has multiple saved
                            // credentials and needs to pick one.
                            resolveResult(status, RC_READ);
                        } else if (status.getStatusCode() == CommonStatusCodes.SIGN_IN_REQUIRED) {
//                            setFragment(null);
                            // This is most likely the case where the user does not currently
                            // have any saved credentials and thus needs to provide a username
                            // and password to sign in.
                            Log.d(TAG, "Sign in required");
                            mSignInButton.setEnabled(true);
                        } else {
                            Log.w(TAG, "Unrecognized status code: " + status.getStatusCode());
//                            setFragment(null);
                            mSignInButton.setEnabled(true);
                        }
                    }
                }
        );
    }
 
开发者ID:obaro,项目名称:SmartLockSample,代码行数:43,代码来源:LoginActivity.java


示例10: requestCredentials

import com.google.android.gms.auth.api.credentials.CredentialRequest; //导入依赖的package包/类
public void requestCredentials(ResultCallback<? super CredentialRequestResult> callback) {
    Auth.CredentialsApi.request(client, new CredentialRequest.Builder()
            .setPasswordLoginSupported(true)
            .setAccountTypes(IdentityProviders.GOOGLE)
            .build()).setResultCallback(callback);
}
 
开发者ID:Sefford,项目名称:BeAuthentic,代码行数:7,代码来源:GoogleApiAdapter.java


示例11: newCredentialRequest

import com.google.android.gms.auth.api.credentials.CredentialRequest; //导入依赖的package包/类
@NonNull CredentialRequest newCredentialRequest() {
    credentialRequest = new CredentialRequest.Builder()
            .setSupportsPasswordLogin(true)
            .build();
    return credentialRequest;
}
 
开发者ID:auth0,项目名称:Lock-SmartLock,代码行数:7,代码来源:SmartLock.java


示例12: RetrieveCredentialObservable

import com.google.android.gms.auth.api.credentials.CredentialRequest; //导入依赖的package包/类
public RetrieveCredentialObservable(Context context, CredentialRequest request) {
    mContext = context;
    mCredentialRequest = request;
}
 
开发者ID:ShlMlkzdh,项目名称:RxSmartLock,代码行数:5,代码来源:RetrieveCredentialObservable.java


示例13: Builder

import com.google.android.gms.auth.api.credentials.CredentialRequest; //导入依赖的package包/类
public Builder(Context context) {
    mContext = context;
    mCredentialRequestBuilder = new CredentialRequest.Builder();
}
 
开发者ID:ShlMlkzdh,项目名称:RxSmartLock,代码行数:5,代码来源:SmartLock.java


示例14: getCredentialRequestBuilder

import com.google.android.gms.auth.api.credentials.CredentialRequest; //导入依赖的package包/类
private CredentialRequest.Builder getCredentialRequestBuilder() {
    return mCredentialRequestBuilder;
}
 
开发者ID:ShlMlkzdh,项目名称:RxSmartLock,代码行数:4,代码来源:SmartLock.java



注:本文中的com.google.android.gms.auth.api.credentials.CredentialRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ClientException类代码示例发布时间:2022-05-23
下一篇:
Java SchemaNamespaceSupport类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap