- Authentication
Implementing single sign-on with Google IDP
OpenID Connect is a powerful feature that enables you to provide single sign-on capabilities for any identity provider that supports the specification. In this tutorial we'll walk you step by step through what you'll need to get single sign-on working by using Google as the identity provider. By the end of this tutorial, you'll be able to sign in via Google and be logged into OrderCloud.
Demo
Before we start, let's take a look at the finished product. Navigate to this website. You will be redirected to Google's sign-in page and after successfully signing in you should see your login details including:
- Currently authenticated user
- OrderCloud Access Token
- OrderCloud Refresh Token (if configured)
- Google ID Token
Marketplace configuration
First, you need to access your Marketplace in the Sitecore Cloud Portal.
After accessing, take special note of the OrderCloud Base API URL, which identifies the base URL needed for all API requests.

For this demonstration we are on the Sandbox environment in the region Us-West so our base API URL is https://sandboxapi.ordercloud.io, yours may look different.
Create supporting entities
We will be creating a single-sign-on experience for buyer users specifically, so we'll create the most basic OrderCloud entities required to support that scenario.
Create a buyer organization
HTTP:
JavaScript:
TypeScript:
C#:
Create security profile
HTTP:
JavaScript:
TypeScript:
C#:
Assign security profile
HTTP:
JavaScript:
TypeScript:
C#:
Create API client
HTTP:
JavaScript:
TypeScript:
C#:
Record the ID from the response for the OpenID Connect configuration.
OpenID Connect configuration
Start ngrok
We'll need a publicly available endpoint. We can use a tool called ngrok to let us do this locally without having to deploy anything. After installing ngrok run the command ngrok http 3000. This tells ngrok to expose our endpoint (not yet running) on http://localhost:3000 to two public endpoints. After running the command copy either one of those URLs and record it, we'll need when creating a new OpenID Connect
We recommend to keep ngrok running. Restarting it will generate unique public endpoints and require you to update your configuration in OrderCloud.
Create integration event
HTTP:
JavaScript:
TypeScript:
C#:
Configure Google
Follow Google's instructions for setting up OpenID Connect configuration on their side. You'll need to set the authorized redirect URI to {ordercloud_base_url}/ocrpcode. Take note of the clientID and clientSecret which OrderCloud will refer to as ConnectClientID and ConnectClientSecret respectively, these values will be needed in the following step.

Create a new OpenID Connect
This entity configures the connection between Google and OrderCloud.
HTTP:
JavaScript:
TypeScript:
C.md#:
Testing
OrderCloud and Google should now be completely configured, and you are ready to test to make sure everything is working. To simplify this aspect, we've created a very minimal frontend to test this functionality.
- Clone this repository
- Install dependencies by running
npm installat the root of the project - Copy
.env.exampleto.env.local - Run the project by running
npm run start. This will start the server on port 3000. Remember ngrok is already listening to this port and will expose our endpoints publicly. - Navigate to the url
http://localhost:3000. If everything is correct you should be redirected to Google's login page. Upon signing in you will be redirected back to the application and should see details about your logged in user
Be sure to look at the /createuser and /syncuser endpoints
Common Issues
Error message: "error validating token with authority"
This issue occurs when OrderCloud attempts to retrieve the ID token from the IDP. This is generally a configuration issue. Confirm ConnectClientID, ConnectClientSecret, and OrderCloudClientID are correct.
Related reading
- Implementing Single Sign On with Azure AD B2C IDP
- Single Sign On via OpenID Connect
- Using Extended Properties