> You are reading the Docusign Developer Documentation. For clean Markdown of any page, append .md to the page URL.
>
> Documentation indexes by section:
> - APIs and SDKs: https://docusign.docs.buildwithfern.com/docs/llms.txt
> - Platform 101: https://docusign.docs.buildwithfern.com/platform/llms.txt
> - Extension Apps: https://docusign.docs.buildwithfern.com/extension-apps/llms.txt
> - Docusign CLI: https://docusign.docs.buildwithfern.com/docusign-cli/llms.txt
>
> Authentication (OAuth, JWT Grant, M2M): https://docusign.docs.buildwithfern.com/platform/auth
> Webhooks and Connect: https://docusign.docs.buildwithfern.com/platform/webhooks
>
> OpenAPI specifications: https://docusign.docs.buildwithfern.com/openapi.json
> MCP server: https://docusign.docs.buildwithfern.com/_mcp/server

# How to log in to Docusign from your app

> Learn how to log in to Docusign from your iOS app.

This topic demonstrates how to log in to Docusign from your app.

## Required data

Running the code in this how-to requires this data:

| Data element               | Description                                                                                                                                                                                                                                                                                                                                                                                                    |
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| \{API_ACCOUNT_ID}          | A [GUID](http://guid.one/) value that identifies your account. This value is automatically generated by Docusign for any account you create. Copy the value from the **API Account ID** field on the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=appsAndKeys) page.                                                                                                                       |
| \{BASE_PATH}               | A string value that forms the root of the URL required to make API calls. The base path value in the example code is set to target the developer environment at https\://\<domain>/restapi Where \<domain> is demo.docusign.net for the developer environment and is the result of the GetUserInfo call in production.                                                                                         |
| \{INTEGRATION_KEY}         | A [GUID](http://guid.one/) value that identifies your app. This can be obtained in your developer account by accessing the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=appsAndKeys) page. See the [Administration Guide](https://support.docusign.com/s/document-item?language=en_US\&rsc_301\&bundleId=pik1583277475390\&topicId=pmp1583277397015.html&_LANG=enus) for more information. |
| \{USER_EMAIL}              | A string value for the email address associated with your account.                                                                                                                                                                                                                                                                                                                                             |
| \{REDIRECT_URI}            | A URL to which the user will be forwarded after authentication. The value for this URL must exactly match one of those pre-registered for the [integration key](/platform/configure-app#integration-key) in your Docusign account. See [redirect URI](/platform/configure-app#redirect-uri) for details.                                                                                                       |
| \{IMPERSONATION_USER_GUID} | A [GUID](http://guid.one/) value that identifies the user. This value is automatically generated by Docusign. Copy the value from the **User ID** field on the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=appsAndKeys) page.                                                                                                                                                             |
| \{USER_NAME}               | A string value for the name associated with your account. This value must exactly match (case-sensitive) the value shown in your [Account Profile](https://admindemo.docusign.com/authenticate?goTo=accountProfile) in the **Name** field.                                                                                                                                                                     |

## Step 1. Obtain your OAuth token

To make the API call shown in this how-to, you need a valid OAuth access token. The Docusign iOS SDK supports access tokens for two different OAuth grant types: Authorization Code Grant and JSON Web Token (JWT) Grant. Choose the OAuth grant type appropriate for your scenario. See [Authenticate](/platform/auth) for guidance on your options to get an OAuth token.

![Three icons that represent the three methods a user can use to obtain an OAuth token: JSON Web Token (JWT), Public Authorization Code Grant (ACG), and Confidential Authorization Code grant](/_fern-files/_img/64f473773042ee439449a096bf7673292b1585b86a4ccc55f82ba0dda41f61a1.webp)

## Step 2.  Enable SDK token storage in Keychain

To enable the SDK to store access tokens and refresh tokens in the [Apple Keychain](https://developer.apple.com/documentation/security/keychain_services), insert the following entry into your application's Info.plist file:

```xml
<key>AppIdentifierPrefix</key>
<string>$(AppIdentifierPrefix)</string>
```

![application info.plist file](/_fern-files/_img/cadc135f43a41b8cbed7696fb1a5e2f8c51b35a4c6a13826af6ed7d74bf98e26.webp)

## Step 3. Log in to Docusign

Use the method shown to log in to Docusign. Be sure to substitute \{ACCESS_TOKEN} for the token obtained in Step 1. This method also includes two optional parameters:

* `refreshToken`: You can use a refresh token to get a new access token after the access token expires. This token is included in the authentication response in Step 1.
* `expiresIn`: A `date` object that indicates the expiration date of the access token.
  If you do not wish to include these parameters, you can set these values to `nil`.

**`Objective-C`**

```text title="Objective-C"
[DSMManager loginWithAccessToken: @"{ACCESS_TOKEN}"
    accountId: @"{ACCOUNT_ID}"
    userId: @"{USER_ID}"
    userName: @"{USER_NAME}"
    email: @"{USER_EMAIL}"@
    host:[NSURL URLWithString: @"{BASE_PATH}"]
    integratorKey:@"{INTEGRATION_KEY}"
    refreshToken:@"{REFRESH_TOKEN}"
    expiresIn:{EXPIRES_IN}
    completion:^(DSMAccountInfo *accountInfo, NSError *error) {

    if (error) {
        NSLog(@"%@", error.localizedDescription);
        return;
    }
}];
```

**`Swift`**

```swift title="Swift"
guard let hostURL = URL(string: "{BASE_PATH}") else {
    return
}
DSMManager.login(withAccessToken: "{ACCESS_TOKEN}",
     accountId: "{ACCOUNT_ID}",
     userId: "{USER_ID}",
     userName: "{USER_NAME}",
     email: "{USER_EMAIL}",
     host: hostURL,
     integratorKey: "{INTEGRATION_KEY}",
     refreshToken: "{REFRESH_TOKEN}",
     expiresIn:  {EXPIRES_IN}) { accountInfo, error in

    if let error = error {
        print("Error logging in: " + error.localizedDescription)
    } else {
        print("Successful Log in!")
    }
}
```

## Expected response

If login is successful, a [DSMAccountInfo](https://docusign.github.io/native-ios-sdk/documentation/docusignsdk/dsmaccountinfo/) object will be returned. You will now be able to make API calls.

## Next steps

* See [How to request a signature online (embedded signing)](/docs/mobile-sdks/ios-sdk/how-to/request-signature-embedded).
* Learn [How to start the signing process for an unsigned envelope without connectivity (offline)](/docs/mobile-sdks/ios-sdk/how-to/start-signing-offline).
* See [How to cache an existing unsigned envelope to use offline](/docs/mobile-sdks/ios-sdk/how-to/cache-envelope).