---
title: "tokenSession(_:beginAuthFor:constraint:)"
framework: cryptotokenkit
role: symbol
role_heading: Instance Method
path: "cryptotokenkit/tktokensessiondelegate/tokensession(_:beginauthfor:constraint:)"
---

# tokenSession(_:beginAuthFor:constraint:)

Tells the delegate that authentication has begun for the specified operation and constraint.

## Declaration

```swift
optional func tokenSession(_ session: TKTokenSession, beginAuthFor operation: TKTokenOperation, constraint: Any) throws -> TKTokenAuthOperation
```

## Parameters

- `session`: The token session.
- `operation`: The kind of operation.
- `constraint`: The constraint to be satisfied.

## Return Value

Return Value The resulting context of the operation, or nil if an error occurred.

## Discussion

Discussion If you return an instance of a subclass of TKTokenAuthOperation that is provided by the CryptoTokenKit framework, the system will first fill in the context-specific properties, such as the password, before calling the finishWithError: method on the context.

## See Also

### Authenticating

- [TKTokenOperationConstraint](cryptotokenkit/tktokenoperationconstraint.md)
- [TKTokenAuthOperation](cryptotokenkit/tktokenauthoperation.md)
- [TKTokenPasswordAuthOperation](cryptotokenkit/tktokenpasswordauthoperation.md)
- [TKTokenSmartCardPINAuthOperation](cryptotokenkit/tktokensmartcardpinauthoperation.md)
