我们如何使用 Docusign Android SDK 方法或其他方式跳过登录或隐式身份验证?

问题描述

我已经在我的应用程序中集成了 docuSign Android SDK 并且能够实现嵌入式签名。但它要求客户在签署文件之前登录。作为面向客户的应用程序,我们不希望他们输入组织文档签名凭据。 我们如何使用 SDK 方法或其他方式跳过登录或隐式身份验证?

提前致谢!!

解决方法

在 Android SDK 中,我们提供以下 api 用于登录或验证。

  1. 使用访问令牌登录:

    您可以调用以下 SDK API:

    // accessToken - Access Token which authenticates the user
    // refreshToken - If the access token can be refreshed,the refresh token. Optional
    // expiresIn - The number of seconds from the time the access token was provisioned to when it will expire
    try {
     DSAuthenticationDelegate docusignAuthDelegate = DocuSign.getInstance().getAuthenticationDelegate();
     docusignAuthDelegate.login(accessToken,refreshToken,expiresIn,context,new DSAuthenticationListener() {
             @Override
             public void onSuccess(@NonNull DSUser user) {
                 // TODO: handle successful authentication here
             }
    
             @Override
             public void onError(@NonNull DSAuthenticationException exception) {
                 // TODO: handle authentication failure here
             }
         }
     );
    } catch (DocuSignNotInitializedException exception) {
     // TODO: handle error. This means the SDK object was not properly initialized
    }
    

    您可以通过以下方式获取访问令牌:

    一个。按照 https://developers.docusign.com/platform/auth/jwt/jwt-get-token/

    中提到的步骤使用 JWT Grant 身份验证

    B.按照 https://developers.docusign.com/platform/auth/authcode/authcode-get-token/

    中提到的步骤使用授权代码授予

    使用 JWT Grant 身份验证来获取访问令牌需要在您的后端实现,一旦您的服务器使用这种方法从 DocuSign 收到访问令牌,那么您的服务器需要将该访问令牌和到期时间传递给您的应用程序和您的应用程序可以调用上面提到的带有访问令牌和过期时间的Android SDK登录api。

  2. 使用 OAuth 登录:

    UI 显示在用户输入凭据的位置。 从您的帐户中获取 OAuth 客户端 ID/集成密钥、密钥和 redirectUri。 (有关如何从您的帐户中检索 clientId、secretKey 和 redirectUri,请参阅https://developers.docusign.com/platform/auth/authcode/authcode-get-token/)。

    在初始化 DocuSign SDk 时,按如下所示传递这些值

     DocuSign.init(
     context,clientId,secretKey,redirectUri,DSMode.DEBUG
    ).setEnvironment(environment)
    
    DSAuthenticationDelegate authenticationDelegate = DocuSign.getInstance().getAuthenticationDelegate();
    authenticationDelegate.login(REQUEST_LOGIN,this,new DSAuthenticationListener() {
    }
    

    这将打开 OAuth 登录屏幕。输入您的用户名和密码,您应该可以登录。

在您的用例中,您可以使用 SDK“使用访问令牌登录”方法。