Basic authentication from backend
How to use basic authentication of Optimizely CMS.
Prerequisites
- Empty or existing Optimizely CMS.
- Optimizely Graph addon.
- Postman.
CMS configuration
- Open your Optimizely CMS solution and install the
Optimizely ContentGraph
addon.
dotnet add Optimizely.ContentGraph.Cms
- 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"
}
},
- Run the website and run the
Optimizely Graph content synchronization job
.
Postman try out
- Import https://cg.optimizely.com/app/swagger/swagger.json to a Postman collection.
- Set up variables for the collection:
- baseUrl –
https://cg.optimizely.com
. - appKey –
AppKey
value (same as above). - appSecret –
Secret
value (same as above).
- baseUrl –
- Setup Authentication method, for simplicity, it should be
Basic
, and put yourappKey
asUsername
andappSecret
asPassword
.
- Start query restricted content items with headers:
cg-username
andcg-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.
Updated 23 days ago