# IRPCLogin.GetPublicKey

Location: [gRPC API](https://developer.m-files.com/APIs/gRPC-API/index.md) > [Vault API](https://developer.m-files.com/APIs/gRPC-API/vault/index.md) > [Login and sessions](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCLogin/index.md)

HTML version: https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCLogin/GetPublicKey/

Badges: `Vault API / core` `session` `session` `idempotent`

Gets the server's RSA public key, for encrypting secrets that a client sends to the server.

- **Service:** [Login and sessions](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCLogin/index.md) `MFiles.IRPCLogin`
- **gRPC method:** `/MFiles.IRPCLogin/GetPublicKey`
- **HTTP (mf-http-grpc):** `POST /grpc/v1/get-public-key`
- **Request:** [`GetPublicKeyRequest`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCLogin/GetPublicKey/index.md#request)
- **Response:** [`GetPublicKeyResponse`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCLogin/GetPublicKey/index.md#response)
- **Book and level:** Vault API, core
- **Kind:** session
- **Session:** Required: the session ID from LogIn in the mfiles-session-id-bin metadata.
- **Idempotent:** yes
- **Returns metadata structure version:** no
- **Streaming:** none (unary)

<a id="remarks"></a>

## Remarks

Used by M-Files clients that encrypt passwords or authentication data above the transport layer.
Over TLS, applications do not need it. The key is a Windows CryptoAPI public key blob.

<a id="request"></a>

## Request: GetPublicKeyRequest

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `password_encryption` | [`PasswordEncryption`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.PasswordEncryption/index.md) | Encryption for which the key is requested. Values: `PASSWORD_ENCRYPTION_RC4` (0), `PASSWORD_ENCRYPTION_UNENCRYPTED` (1), `PASSWORD_ENCRYPTION_AES256` (2). |

<a id="response"></a>

## Response: GetPublicKeyResponse

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `public_key` | `bytes` | Receives the public key as a BLOB. |

<a id="related"></a>

## Related methods

- [GetPublicKeyAnonymous](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCLogin/GetPublicKeyAnonymous/index.md): Gets the server's RSA public key without a session, for encrypting authentication data before login.
