Exposing an Integration Object as an API
Follow the steps to expose an example Integration Object with OAuth 2.0 authentication.
Context
Complete each of the following procedures to configure an example Integration Object for enhanced authorization. The example uses ImpEx and specifies OAuth authorization. To configure an Integration Object for Basic authorization, replace the OAuth values with Basic values.
For a complete description of enhanced authorization and authentication and other Integration API security features, see Integration API Security.
Create an Integration Object
Context
Click the arrow to expand the code example.
INSERT_UPDATE IntegrationObject; code[unique = true];
; MyOauthExampleIO ;
INSERT_UPDATE IntegrationObjectItem; integrationObject(code)[unique = true]; code[unique = true]; type(code) ; root[default = false];
; MyOauthExampleIO ; Product ; Product ; true ;
; MyOauthExampleIO ; Catalog ; Catalog ; ;
; MyOauthExampleIO ; CatalogVersion ; CatalogVersion ; ;
INSERT_UPDATE IntegrationObjectItemAttribute; integrationObjectItem(integrationObject(code), code)[unique = true]; attributeName[unique = true]; attributeDescriptor(enclosingType(code), qualifier); returnIntegrationObjectItem(integrationObject(code), code); unique[default = false]; autoCreate[default = false];
; MyOauthExampleIO:Product ; code ; Product:code ;
; MyOauthExampleIO:Product ; catalogVersion ; Product:catalogVersion ; MyOauthExampleIO:CatalogVersion ; ; ;
; MyOauthExampleIO:Product ; name ; Product:name ; ; ; ;
; MyOauthExampleIO:Product ; anotherName ; Product:name ; ; ; ;
; MyOauthExampleIO:Product ; onlineDate ; Product:onlineDate ; ; ; ;
; MyOauthExampleIO:Catalog ; id ; Catalog:id ; ; ; ;
; MyOauthExampleIO:CatalogVersion ; catalog ; CatalogVersion:catalog ; MyOauthExampleIO:Catalog ; ; ;
; MyOauthExampleIO:CatalogVersion ; version ; CatalogVersion:version ;
; MyOauthExampleIO:CatalogVersion ; active ; CatalogVersion:active ; ; ; ;
Create an InboundChannelConfiguration
Context
You can create an InboundChannelConfiguration (ICC) by importing an ImpEx file or in Backoffice.
Import the following ImpEx example to create an InboundChannelConfiguration for an Integration Object called MyOauthExampleIO with an inbound channel value of OAUTH.
INSERT_UPDATE InboundChannelConfiguration; integrationObject(code)[unique = true]; authenticationType(code);
; MyOauthExampleIO ; OAUTH ;
Configure the Client Grant Type for OAuth
Context
The client grant type associates a user with a client and a client with a session. The IntegrationClientCredentialsDetailsitem type defines the user authorized to make requests in a session. The item type extends the type system's client_credentials grant type and supports only the OAuth authentication flow.
Import the following ImpEx to configure the oauthexampleClient as a user.
INSERT_UPDATE IntegrationClientCredentialsDetails; clientId[unique = true]; resourceIds; authorities ; clientSecret; registeredRedirectUri ; user(uid) ;
; oauthexampleClient ; hybris ; ROLE_INTEGRATIONADMINGROUP ; userpassword ; https://localhost:9002/oauth2_implicit_callback ; oauthexampleUser ;
INSERT_UPDATE Employee; name ; UID[unique = true]; groups(uid) ; password; loginDisabled;
; oauthexampleUser ; oauthexampleUser ; integrationadmingroup ; userpassword ; ;
Grant Access Permissions by User Group
Context
You can grant access permissions by ImpEx or Backoffice. The following example uses Backoffice.
Procedure
- In the Administration Cockpit perspective, select .
- Select the type that comprises the Integration Object. In this example, one of the types is Product.
- Select the Type Permission Action icon.
- Locate the role associated with user created for the client grant type. Click the icons to toggle the permissions for each action type available. A checkmark grants permission and an x denies permission. For this example, grant access to Read so the user can make a GET request. Close the Permission Management window when done.
- Repeat this process for each type included in the Integration Object to ensure the user can interact with all of the Integration Object's item types.
Retrieve an OAuth Endpoint
Context
The following example returns the metadata for the MyOauthExampleIO Integration Object you created, authenticated, and secured with OAuth in the preceding steps.
To retrieve an access token for an OAuth request, provide:
- Grant Type - client credentials
- Access Token URL
- Client ID
- Client Secret
Example Request URL
GET https://localhost:9002/odata2webservices/MyOauthExampleIO/$metadata
Example Response Body
A successful request returns a 200 OK response.
<?xml version='1.0' encoding='UTF-8'?>
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
<edmx:DataServices m:DataServiceVersion="1.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<Schema Namespace="HybrisCommerceOData" xmlns="http://schemas.microsoft.com/ado/2008/09/edm" s:schema-version="1" xmlns:s="http://schemas.sap.com/commerce">
<EntityType Name="Localized___Product">
<Key>
<PropertyRef Name="language"/>
</Key>
<Property Name="name" Type="Edm.String" s:IsLanguageDependent="true" Nullable="true"/>
<Property Name="anotherName" Type="Edm.String" s:IsLanguageDependent="true" Nullable="true"/>
<Property Name="language" Type="Edm.String" Nullable="false"/>
</EntityType>
<EntityType Name="CatalogVersion">
<Key>
<PropertyRef Name="integrationKey"/>
</Key>
<Property Name="active" Type="Edm.Boolean" Nullable="true"/>
<Property Name="version" Type="Edm.String" Nullable="false" s:IsUnique="true"/>
<Property Name="integrationKey" Type="Edm.String" Nullable="false" s:Alias="CatalogVersion_version|Catalog_id"/>
<NavigationProperty Name="catalog" Relationship="HybrisCommerceOData.FK_CatalogVersion_catalog" FromRole="CatalogVersion" ToRole="Catalog" s:IsUnique="true" Nullable="false"/>
</EntityType>
<EntityType Name="Product">
<Key>
<PropertyRef Name="integrationKey"/>
</Key>
<Property Name="onlineDate" Type="Edm.DateTime" Nullable="true"/>
<Property Name="name" Type="Edm.String" s:IsLanguageDependent="true" Nullable="true"/>
<Property Name="code" Type="Edm.String" Nullable="false" s:IsUnique="true"/>
<Property Name="anotherName" Type="Edm.String" s:IsLanguageDependent="true" Nullable="true"/>
<Property Name="integrationKey" Type="Edm.String" Nullable="false" s:Alias="CatalogVersion_version|Catalog_id|Product_code"/>
<NavigationProperty Name="catalogVersion" Relationship="HybrisCommerceOData.FK_Product_catalogVersion" FromRole="Product" ToRole="CatalogVersion" s:IsUnique="true" Nullable="false"/>
<NavigationProperty Name="localizedAttributes" Relationship="HybrisCommerceOData.FK_Product_localizedAttributes" FromRole="Product" ToRole="Localized___Product" Nullable="true"/>
</EntityType>
<EntityType Name="Catalog">
<Key>
<PropertyRef Name="integrationKey"/>
</Key>
<Property Name="id" Type="Edm.String" Nullable="false" s:IsUnique="true"/>
<Property Name="integrationKey" Type="Edm.String" Nullable="false" s:Alias="Catalog_id"/>
</EntityType>
<Association Name="FK_Product_catalogVersion">
<End Type="HybrisCommerceOData.Product" Multiplicity="0..1" Role="Product"/>
<End Type="HybrisCommerceOData.CatalogVersion" Multiplicity="0..1" Role="CatalogVersion"/>
</Association>
<Association Name="FK_CatalogVersion_catalog">
<End Type="HybrisCommerceOData.CatalogVersion" Multiplicity="0..1" Role="CatalogVersion"/>
<End Type="HybrisCommerceOData.Catalog" Multiplicity="0..1" Role="Catalog"/>
</Association>
<Association Name="FK_Product_localizedAttributes">
<End Type="HybrisCommerceOData.Product" Multiplicity="1" Role="Product"/>
<End Type="HybrisCommerceOData.Localized___Product" Multiplicity="*" Role="Localized___Product"/>
</Association>
<EntityContainer Name="Container" m:IsDefaultEntityContainer="true">
<EntitySet Name="Localized___Products" EntityType="HybrisCommerceOData.Localized___Product"/>
<EntitySet Name="CatalogVersions" EntityType="HybrisCommerceOData.CatalogVersion"/>
<EntitySet Name="Products" EntityType="HybrisCommerceOData.Product"/>
<EntitySet Name="Catalogs" EntityType="HybrisCommerceOData.Catalog"/>
<AssociationSet Name="Product_CatalogVersions" Association="HybrisCommerceOData.FK_Product_catalogVersion">
<End EntitySet="Products" Role="Product"/>
<End EntitySet="CatalogVersions" Role="CatalogVersion"/>
</AssociationSet>
<AssociationSet Name="CatalogVersion_Catalogs" Association="HybrisCommerceOData.FK_CatalogVersion_catalog">
<End EntitySet="CatalogVersions" Role="CatalogVersion"/>
<End EntitySet="Catalogs" Role="Catalog"/>
</AssociationSet>
<AssociationSet Name="Product_Localized___Products" Association="HybrisCommerceOData.FK_Product_localizedAttributes">
<End EntitySet="Products" Role="Product"/>
<End EntitySet="Localized___Products" Role="Localized___Product"/>
</AssociationSet>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>

