Basic authentication from backend
How to use basic authentication of Optimizely CMS.
Prerequisites
- Optimizely CMS
- Optimizely Graph addon (only PaaS)
- Postman or cURL
CMS configuration
Setup (PaaS only)
- Open your Optimizely CMS solution and install the
Optimizely ContentGraphaddon.
dotnet add Optimizely.ContentGraph.Cms- Update the
appsetting.jsonfile. (You should get this information from the Optimizely Support team).
"Optimizely": {
"ContentGraph": {
"GatewayAddress": "",
"AppKey": "",
"Secret": "",
"SingleKey": "",
"AllowSendingLog": "true",
"ContentVersionSyncMode": "All",
"SyncReferencingContents": "true",
"EnablePreviewTokens": "true"
}
},Config
- Set access rights for contents
- Run the website and run the
Optimizely Graph content synchronization job.
Retrieve restricted content
Postman
- 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 –
AppKeyvalue (same as above). - appSecret –
Secretvalue (same as above).
- baseUrl –
- Configure the Authentication method, for simplicity, it should be
Basic, and put yourappKeyasUsernameandappSecretasPassword.
- Start query restricted content items with headers:
cg-usernameandcg-roles:
Note
- cg-username – Optimizely CMS user.
- cg-roles – Optimizely CMS roles to access specific content items.
.HTTP
POST {{graphDomain}}/content/v2
Content-Type: application/json
Authorization: Basic {{graphBase64EncodedToken}}
cg-roles: Administrators
{ "query" :"query { ProductPage { total } }" }Updated 20 days ago
