@@ -12,10 +12,19 @@ dotnet tool install -g contentstack.model.generator
1212## How to use
1313Once you install ``` contentstack.model.generator ``` run ``` --help ``` to view available commands.
1414
15+ ### Authentication Methods
16+
17+ The Contentstack Model Generator supports two authentication methods:
18+
19+ 1 . ** Traditional Authtoken Authentication** (default)
20+ 2 . ** OAuth 2.0 Authentication**
21+
22+ ### Command Line Options
23+
1524| Short key | Long Key | Description |
1625| -- | -- | -- |
1726| ` -a ` | ` --api-key ` | The Stack API key for the Content Management API |
18- | ` -A ` | ` --authtoken ` | The Authtoken for the Content Management API |
27+ | ` -A ` | ` --authtoken ` | The Authtoken for the Content Management API (required for traditional auth) |
1928| ` -b ` | ` --branch ` | The branch header in the API request to fetch or manage modules located within specific branches. |
2029| ` -e ` | ` --endpoint ` | The Contentstack Host for the Content Management API |
2130| ` -n ` | ` --namespace ` | The namespace the classes should be created in |
@@ -25,33 +34,115 @@ Once you install ```contentstack.model.generator``` run ```--help``` to view av
2534| ` -g ` | ` --group-prefix ` | The Group Class Prefix. |
2635| ` -p ` | ` --path ` | Path to the file or directory to create files in. |
2736
28- ### Example 1
37+ ### OAuth 2.0 Options
38+
39+ | Long Key | Description |
40+ | -- | -- |
41+ | ` --oauth ` | Enable OAuth 2.0 authentication (mutually exclusive with traditional auth) |
42+ | ` --client-id ` | OAuth Client ID (required for OAuth) (Default Value: Ie0FEfTzlfAHL4xM ) |
43+ | ` --client-secret ` | OAuth Client Secret (optional for public clients using PKCE) |
44+ | ` --redirect-uri ` | OAuth Redirect URI (required for OAuth) (Default Value: http://localhost:8184 ) |
45+ | ` --app-id ` | OAuth App ID (optional) ( Default Value: 6400aa06db64de001a31c8a9 ) |
46+ | ` --scopes ` | OAuth Scopes (optional, space-separated) |
47+
48+ ## Examples
49+
50+ ### Traditional API Key Authentication
51+
52+ #### Example 1: Basic Usage
2953To create classes in current directory run following command:
3054```
3155contentstack.model.generator -a <stack_api_key> -A <authtoken>
3256```
3357
34- ### Example 2
58+ #### Example 2: Specific Path
3559To create classes in specific path run following command:
3660```
3761contentstack.model.generator -a <stack_api_key> -A <authtoken> -p /User/xxx/Desktop
3862```
3963
40- ### Example 3
64+ #### Example 3: With Namespace
4165To create classes with namespace run following command:
4266```
4367contentstack.model.generator -a <stack_api_key> -A <authtoken> -n YourProject.Models
4468```
4569
46- ### Example 4
47- To allow ` Nullable ` annotation context in model creation run following command
70+ #### Example 4: With Nullable Annotations
71+ To allow ` Nullable ` annotation context in model creation run following command:
4872```
4973contentstack.model.generator -a <stack_api_key> -A <authtoken> -N
5074```
5175
76+ ### OAuth 2.0 Authentication
77+
78+ #### Example 5: OAuth with PKCE (Recommended)
79+ For public clients or enhanced security, use OAuth with PKCE:
80+ ```
81+ contentstack.model.generator --oauth -a <stack_api_key> --client-id <client_id> --redirect-uri http://localhost:8184
82+ ```
83+
84+ #### Example 6: OAuth with Client Secret
85+ For confidential clients with client secret:
86+ ```
87+ contentstack.model.generator --oauth -a <stack_api_key> --client-id <client_id> --client-secret <client_secret> --redirect-uri http://localhost:8184
88+ ```
89+
90+ #### Example 7: OAuth with App ID
91+ For OAuth with specific app:
92+ ```
93+ contentstack.model.generator --oauth -a <stack_api_key> --client-id <client_id> --redirect-uri http://localhost:8184 --app-id <app_id>
94+ ```
95+
96+ #### Example 8: OAuth with Custom Path and Namespace
97+ ```
98+ contentstack.model.generator --oauth -a <stack_api_key> --client-id <client_id> --redirect-uri http://localhost:8184 -p /path/to/models -n YourProject.Models
99+ ```
100+
101+ ## OAuth Command Example
102+
103+ Here's what you'll see when running an OAuth command:
104+
105+ ``` bash
106+
107+ $ contentstack.model.generator --oauth -a < api_key> --client-id myclient123 --redirect-uri http://localhost:8184
108+
109+ Contentstack Model Generator v0.5.0
110+ =====================================
111+
112+ OAuth Authentication Required
113+ =============================
114+
115+ Please open the following URL in your browser to authorize the application:
116+
117+ https://app.contentstack.com/#! /apps/6400aa06db64de001a31c8a9/authorize?response_type=code&client_id=myclient123&redirect_uri=http%3A%2F%2Flocalhost%3A8184&code_challenge=...
118+
119+ After authorization, you will be redirected to a local URL.
120+ Please copy the ' code' parameter from the redirect URL and paste it here:
121+
122+ Authorization code: [User pastes the code here]
123+
124+ Exchanging authorization code for access token...
125+ OAuth authentication successful!
126+ Access token expires at: 2024-01-15 14:30:00 UTC
127+
128+ Fetching stack information...
129+ Stack: My Contentstack Stack
130+ API Key: api_key
131+
132+ Fetching content types...
133+ Found 5 content types:
134+ Generating files from content type
135+
136+ Files successfully created!
137+ Opening < file_path> /Models
138+
139+ Logging out from OAuth...
140+ OAuth logout successful!
141+ ```
142+
52143### MIT License
53144
54- Copyright (c) 2012-2024 Contentstack
145+ Copyright (c) 2012-2025 Contentstack
55146
56147Permission is hereby granted, free of charge, to any person obtaining a copy
57148of this software and associated documentation files (the "Software"), to deal
0 commit comments