# OAuthCredentialService

> The OAuthCredentialService methods and their request and response messages.

Source: https://engramsfactory.com/docs/api/oauth-credential/

Generated from [`oauth.proto`](https://github.com/cortexapps/engrams/blob/main/crates/engram-protocol/proto/engram/app/v1/oauth.proto). Every method is
`POST /rpc/engram.app.v1.OAuthCredentialService/<Method>` with a JSON or protobuf body and an
`x-api-key` header.

## Methods

| Method | Request | Response |
|---|---|---|
| `BeginFlow` | [`BeginFlowRequest`](#beginflowrequest) | [`BeginFlowResponse`](#beginflowresponse) |
| `GetFlow` | [`GetFlowRequest`](#getflowrequest) | [`GetFlowResponse`](#getflowresponse) |
| `CancelFlow` | [`CancelFlowRequest`](#cancelflowrequest) | [`CancelFlowResponse`](#cancelflowresponse) |
| `ListCredentials` | [`ListCredentialsRequest`](#listcredentialsrequest) | [`ListCredentialsResponse`](#listcredentialsresponse) |
| `Disconnect` | [`DisconnectRequest`](#disconnectrequest) | [`DisconnectResponse`](#disconnectresponse) |
| `PutCredential` | [`PutCredentialRequest`](#putcredentialrequest) | [`PutCredentialResponse`](#putcredentialresponse) |
| `LookupRedirectFlow` | [`LookupRedirectFlowRequest`](#lookupredirectflowrequest) | [`LookupRedirectFlowResponse`](#lookupredirectflowresponse) |
| `BeginRedirectFlow` | [`BeginRedirectFlowRequest`](#beginredirectflowrequest) | [`BeginRedirectFlowResponse`](#beginredirectflowresponse) |
| `CompleteRedirectFlow` | [`CompleteRedirectFlowRequest`](#completeredirectflowrequest) | [`CompleteRedirectFlowResponse`](#completeredirectflowresponse) |
| `GrantClientCredentials` | [`GrantClientCredentialsRequest`](#grantclientcredentialsrequest) | [`GrantClientCredentialsResponse`](#grantclientcredentialsresponse) |
| `GrantServiceAccount` | [`GrantServiceAccountRequest`](#grantserviceaccountrequest) | [`GrantServiceAccountResponse`](#grantserviceaccountresponse) |
| `FetchSessionCredential` | [`FetchSessionCredentialRequest`](#fetchsessioncredentialrequest) | [`FetchSessionCredentialResponse`](#fetchsessioncredentialresponse) |
| `UpdateSessionCredential` | [`UpdateSessionCredentialRequest`](#updatesessioncredentialrequest) | [`UpdateSessionCredentialResponse`](#updatesessioncredentialresponse) |

## Messages

### BeginFlowRequest

| Field | Type |
|---|---|
| `subject` | [`OAuthSubject`](#oauthsubject) |
| `provider` | `string` |

### BeginFlowResponse

| Field | Type |
|---|---|
| `flow` | [`OAuthFlow`](#oauthflow) |
| `verification_url` | `string` |
| `user_code` | `string` |

### BeginRedirectFlowRequest

| Field | Type |
|---|---|
| `subject` | [`OAuthSubject`](#oauthsubject) |
| `provider` | `string` |
| `spec` | [`RedirectOauthSpec`](#redirectoauthspec) |
| `redirect_uri` | `string` |

### BeginRedirectFlowResponse

| Field | Type |
|---|---|
| `flow` | [`OAuthFlow`](#oauthflow) |
| `authorize_url` | `string` |

### CancelFlowRequest

| Field | Type |
|---|---|
| `subject` | [`OAuthSubject`](#oauthsubject) |
| `flow_id` | `string` |

### CancelFlowResponse

| Field | Type |
|---|---|
| `flow` | [`OAuthFlow`](#oauthflow) |

### ClientCredentialsSpec

| Field | Type |
|---|---|
| `token_url` | `string` |
| `scopes` | repeated `string` |
| `scope_delimiter` | `string` |
| `client_id_ref` | `string` |
| `client_secret_ref` | `string` |
| `token_request_body` | `string` |
| `metadata` | [`RedirectMetadataSpec`](#redirectmetadataspec) |

### CompleteRedirectFlowRequest

| Field | Type |
|---|---|
| `subject` | [`OAuthSubject`](#oauthsubject) |
| `provider` | `string` |
| `flow_id` | `string` |
| `code` | `string` |
| `redirect_uri` | `string` |
| `spec` | [`RedirectOauthSpec`](#redirectoauthspec) |

### CompleteRedirectFlowResponse

| Field | Type |
|---|---|
| `credential` | [`OAuthCredentialMeta`](#oauthcredentialmeta) |

### DisconnectRequest

| Field | Type |
|---|---|
| `subject` | [`OAuthSubject`](#oauthsubject) |
| `provider` | `string` |
| `expected_version` | `int64` |

### DisconnectResponse

| Field | Type |
|---|---|
| `credential` | [`OAuthCredentialMeta`](#oauthcredentialmeta) |

### FetchSessionCredentialRequest

| Field | Type |
|---|---|
| `session_id` | `string` |
| `broker_token` | `string` |

### FetchSessionCredentialResponse

| Field | Type |
|---|---|
| `provider` | `string` |
| `version` | `int64` |
| `opaque_bundle` | `bytes` |

### GetFlowRequest

| Field | Type |
|---|---|
| `subject` | [`OAuthSubject`](#oauthsubject) |
| `flow_id` | `string` |

### GetFlowResponse

| Field | Type |
|---|---|
| `flow` | [`OAuthFlow`](#oauthflow) |

### GrantClientCredentialsRequest

| Field | Type |
|---|---|
| `subject` | [`OAuthSubject`](#oauthsubject) |
| `provider` | `string` |
| `spec` | [`ClientCredentialsSpec`](#clientcredentialsspec) |

### GrantClientCredentialsResponse

| Field | Type |
|---|---|
| `credential` | [`OAuthCredentialMeta`](#oauthcredentialmeta) |

### GrantServiceAccountRequest

| Field | Type |
|---|---|
| `subject` | [`OAuthSubject`](#oauthsubject) |
| `provider` | `string` |
| `spec` | [`ServiceAccountSpec`](#serviceaccountspec) |

### GrantServiceAccountResponse

| Field | Type |
|---|---|
| `credential` | [`OAuthCredentialMeta`](#oauthcredentialmeta) |

### ListCredentialsRequest

| Field | Type |
|---|---|
| `subject` | [`OAuthSubject`](#oauthsubject) |

### ListCredentialsResponse

| Field | Type |
|---|---|
| `credentials` | repeated [`OAuthCredentialMeta`](#oauthcredentialmeta) |

### LookupRedirectFlowRequest

| Field | Type |
|---|---|
| `flow_id` | `string` |

### LookupRedirectFlowResponse

| Field | Type |
|---|---|
| `subject` | [`OAuthSubject`](#oauthsubject) |
| `provider` | `string` |
| `status` | `string` |

### OAuthAccountMetadata

| Field | Type |
|---|---|
| `display_name` | `string` (optional) |
| `plan_type` | `string` (optional) |
| `workspace_id` | `string` (optional) |
| `workspace_name` | `string` (optional) |

### OAuthCredentialMeta

| Field | Type |
|---|---|
| `provider` | `string` |
| `version` | `int64` |
| `connected` | `bool` |
| `account` | [`OAuthAccountMetadata`](#oauthaccountmetadata) |
| `created_at` | `string` |
| `updated_at` | `string` |
| `status` | `string` |
| `expires_at` | `string` |
| `subject_id` | `string` |

### OAuthFlow

| Field | Type |
|---|---|
| `id` | `string` |
| `provider` | `string` |
| `status` | `string` |
| `error_code` | `string` (optional) |
| `expires_at` | `string` |
| `updated_at` | `string` |

### OAuthSubject

| Field | Type |
|---|---|
| `kind` | [`OauthSubjectKind`](#oauthsubjectkind) |
| `id` | `string` |

### PutCredentialRequest

| Field | Type |
|---|---|
| `subject` | [`OAuthSubject`](#oauthsubject) |
| `provider` | `string` |
| `secret` | `string` |
| `identity` | [`RedirectMetadataProbe`](#redirectmetadataprobe) |

### PutCredentialResponse

| Field | Type |
|---|---|
| `credential` | [`OAuthCredentialMeta`](#oauthcredentialmeta) |

### RedirectMetadataProbe

| Field | Type |
|---|---|
| `method` | `string` |
| `host` | `string` |
| `path` | `string` |
| `body` | `string` |
| `map` | `map<string, string>` |

### RedirectMetadataSpec

| Field | Type |
|---|---|
| `from_token_response` | `map<string, string>` |
| `probe` | [`RedirectMetadataProbe`](#redirectmetadataprobe) |

### RedirectOauthSpec

| Field | Type |
|---|---|
| `authorize_url` | `string` |
| `token_url` | `string` |
| `scopes` | repeated `string` |
| `scope_delimiter` | `string` |
| `extra_authorize_params` | `map<string, string>` |
| `client_id_ref` | `string` |
| `client_secret_ref` | `string` |
| `pkce` | `bool` |
| `metadata` | [`RedirectMetadataSpec`](#redirectmetadataspec) |
| `scopes_param` | `string` |
| `grant_path` | `string` |

### ServiceAccountSpec

| Field | Type |
|---|---|
| `token_url` | `string` |
| `scopes` | repeated `string` |
| `scope_delimiter` | `string` |
| `key_ref` | `string` |
| `subject` | `string` |
| `metadata` | [`RedirectMetadataSpec`](#redirectmetadataspec) |

### UpdateSessionCredentialRequest

| Field | Type |
|---|---|
| `session_id` | `string` |
| `broker_token` | `string` |
| `expected_version` | `int64` |
| `opaque_bundle` | `bytes` |

### UpdateSessionCredentialResponse

| Field | Type |
|---|---|
| `provider` | `string` |
| `version` | `int64` |
| `opaque_bundle` | `bytes` |

## Enums

### OauthSubjectKind

| Value | Number |
|---|---|
| `OAUTH_SUBJECT_KIND_UNSPECIFIED` | 0 |
| `OAUTH_SUBJECT_KIND_USER` | 1 |
| `OAUTH_SUBJECT_KIND_CONNECTOR` | 2 |
| `OAUTH_SUBJECT_KIND_MCP` | 3 |
| `OAUTH_SUBJECT_KIND_USER_CONNECTOR` | 4 |
