HomeDev guideAPI ReferenceGraphQL
Dev guideUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Basic authentication from backend

How to use basic authentication of Optimizely CMS.

Prerequisites

  • Empty or existing Optimizely CMS.
  • Optimizely Graph addon.
  • Postman.

CMS configuration

  1. Open your Optimizely CMS solution and install theOptimizely ContentGraph addon.
dotnet add Optimizely.ContentGraph.Cms
  1. Update the appsetting.json file. (You should get this information from the Optimizely Support team).
"Optimizely": {
    "ContentGraph": {
      "GatewayAddress": "",
      "AppKey": "",
      "Secret": "",
      "SingleKey": "",
      "AllowSendingLog": "true",
      "ContentVersionSyncMode": "All",
      "SyncReferencingContents": "true",
      "EnablePreviewTokens": "true"
    }
  },
  1. Run the website and run theOptimizely Graph content synchronization job.

Postman try out

  1. Import https://cg.optimizely.com/app/swagger/swagger.json to a Postman collection.
  2. Set up variables for the collection:
    • baseUrlhttps://cg.optimizely.com.
    • appKeyAppKey value (same as above).
    • appSecretSecret value (same as above).

  1. Setup Authentication method, for simplicity, it should be Basic, and put your appKey as Username and appSecret as Password.

  1. Start query restricted content items with headers: cg-username and cg-roles:
curl --location 'https://dev.cg.optimizely.com/content/v2' \
--header 'Content-Type: application/json' \
--header 'cg-roles: ["Everyone", "dministrators"]' \
--header 'cg-username: admin' \
--header 'Authorization: Basic V25KQmNtUlpSNTFYaDJuSmExMDRWV1BYZkcydlcxZUluOkYwaWRhcDRPQ1ZOc0JSQTJmdVpCVDNtYXVoaVl1QWtRcDM5SHduazB2dW1XblpoZytjbmg4QnpHVU5VQlVIYTM=' \
--data '{"query":"{\n    Content {\n        items {\n            Name\n            Status\n        }\n    }\n}","variables":{}}'

📘

Note

  • cg-username – Optimizely CMS user.
  • cg-roles – Optimizely CMS roles to access specific content items.