Orchardcore twitter

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore twitter is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for integrating X Twitter in Orchard Core. Covers TwitterClient, X API settings, sign in with X Twitter, TwitterSettings, TwitterSigninSettings, ConfigureTwitterSettings with the OrchardCore X configuration section, ConsumerSecret and AccessTokenSecret from configuration or the Secrets module,

How to use this skill

Skill file

Orchard Core X Twitter Integration

The X Twitter module has two distinct features. OrchardCore.Twitter configures

the API client and workflow status activity. OrchardCore.Twitter.Signin

depends on it and OrchardCore.Users.ExternalAuthentication to add external

sign-in. Configure API credentials with the minimum provider permissions

required for the selected capability.

Guidelines

Enable X Integration

{
  "steps": [
    {
      "name": "Feature",
      "enable": [
        "OrchardCore.Twitter"
      ],
      "disable": []
    }
  ]
}

For sign-in, add OrchardCore.Twitter.Signin:

{
  "steps": [
    {
      "name": "Feature",
      "enable": [
        "OrchardCore.Twitter",
        "OrchardCore.Twitter.Signin"
      ],
      "disable": []
    }
  ]
}

Configure API Credentials

Configure them at Settings → Integrations → X (Twitter). TwitterSettings contains the OAuth credentials used by TwitterClient:

| Property | Purpose |

|---|---|

| ConsumerKey | Application consumer key. |

| ConsumerSecret | Application consumer secret. |

| AccessToken | Account access token for API operations. |

| AccessTokenSecret | Account access-token secret. |

| ConsumerSecretSecretName, AccessTokenSecretSecretName | 4.0. Names of TextSecret entries of the Secrets module; each takes precedence over its protected value. |

With the OrchardCore.Secrets feature enabled, both secret editors offer

Use a secret (suggested names Twitter.ConsumerSecret and

Twitter.AccessTokenSecret), and saved values can be moved without retyping

them from Tools → Security → Migrate Secrets. The generic Settings step

can set the two *SecretName properties in TwitterSettings after a

Secrets step created the secrets; the TwitterSettings step has no

secret-name properties. See orchardcore-secrets.

The recipe step name is TwitterSettings (the generic Settings step with a

TwitterSettings object works too). The client decrypts the stored secrets

with data protection, as saved from the admin page, so secrets imported by a

recipe are stored as is and fail to decrypt. Prefer the admin page or

configuration for ConsumerSecret and AccessTokenSecret; the step replaces

all four values, so re-running it clears secrets entered earlier.

{
  "steps": [
    {
      "name": "TwitterSettings",
      "ConsumerKey": "consumer-key",
      "AccessToken": "access-token"
    }
  ]
}

For configuration overrides, call ConfigureTwitterSettings() on the

OrchardCoreBuilder and use the OrchardCore:X section:

builder.Services
    .AddOrchardCms()
    .ConfigureTwitterSettings();
{
  "OrchardCore": {
    "X": {
      "ConsumerKey": "consumer-key",
      "ConsumerSecret": "plain-consumer-secret",
      "AccessToken": "access-token",
      "AccessTokenSecret": "plain-access-token-secret"
    }
  }
}

ConsumerSecret and AccessTokenSecret are plain values here (for example

from OrchardCore__X__ConsumerSecret environment variables or a key vault);

Orchard Core protects them before use. In 4.0 they log a

LegacySecretConfiguration warning (event 8100); move them to secrets.

Sign In With X

Configure Settings → Security → Authentication → Sign In with X (Twitter).

The sign-in settings model exposes CallbackPath and SaveTokens; the

consumer key and secret come from the API settings above. Set CallbackPath

explicitly (for example /signin-x) and register the same full tenant URL as

the X app's callback URL. The sign-in startup registers

the authentication and provider-specific options configurations plus the

external login display driver.

Update X Status in a Workflow

Enable OrchardCore.Workflows in addition to OrchardCore.Twitter. The module

registers Update X (Twitter) Status Task. Its StatusTemplate is evaluated

through the workflow expression evaluator before TwitterClient.UpdateStatus

is called.

{
  "steps": [
    {
      "name": "Feature",
      "enable": [
        "OrchardCore.Twitter",
        "OrchardCore.Workflows"
      ],
      "disable": []
    }
  ]
}

Branch on Failed and avoid blindly retrying status updates in a workflow,

because a request may have reached the provider even if the response was lost.

Use TwitterClient Programmatically

Inject the registered typed client rather than creating an unauthenticated

HttpClient:

using OrchardCore.Twitter.Services;

namespace MyModule;

public sealed class SocialUpdateService
{
    private readonly TwitterClient _twitterClient;

    public SocialUpdateService(TwitterClient twitterClient)
    {
        _twitterClient = twitterClient;
    }

    public Task<HttpResponseMessage> PublishAsync(string status)
    {
        return _twitterClient.UpdateStatus(status);
    }
}

Check the response status before reporting success and respect X platform

limits and policies.

Upgrading from 3.x

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.