Skip to content

Commit 166f25c

Browse files
Add new pages to the examples covering the Auth procedures
- Add OAuth2 Authorization Code Flow example (py-oauth2-authorization-code/) - Complete flow with local callback server for OAuth redirect - Token refresh demonstration - Production-ready patterns with error handling - Add OAuth2 Client Credentials Flow example (py-oauth2-client-credentials/) - Robot/service account authentication - Reusable OAuth2ClientCredentials class with automatic token management - Multiple authentication method examples (Basic Auth, body params) - Add OAuth1 example (py-oauth1/) - Legacy authentication support - Complete 3-legged OAuth1 flow - Migration guidance to OAuth2 - Add AUTH_README.md with: - Decision guide for choosing authentication method - Quick comparison table - Security best practices - Troubleshooting guide - Update main readme.md with authentication section and example index Each example includes Python script, README with usage instructions, and requirements.txt for dependencies. https://planview.projectplace.com/#direct/card/26044157
1 parent cd75b63 commit 166f25c

File tree

14 files changed

+1936
-6
lines changed

14 files changed

+1936
-6
lines changed

examples/AUTH_README.md

Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
# Authentication Mechanisms for Planview ProjectPlace API
2+
3+
This directory contains examples for all supported authentication methods for the Planview ProjectPlace API.
4+
5+
## Available Authentication Methods
6+
7+
### 1. OAuth2 Authorization Code Flow ⭐ Recommended for User Access
8+
**Directory**: `py-oauth2-authorization-code/`
9+
10+
Use this when you need to access resources **on behalf of a user**.
11+
12+
**Best for:**
13+
- Web applications
14+
- Mobile apps
15+
- Desktop applications
16+
- Any integration where users authorize your app to access their data
17+
18+
**Key Features:**
19+
- User authorizes your application
20+
- Access tokens valid for 30 days
21+
- Refresh tokens valid for 120 days
22+
- Can maintain indefinite access with refresh tokens
23+
24+
[View Example →](./py-oauth2-authorization-code)
25+
26+
---
27+
28+
### 2. OAuth2 Client Credentials Flow ⭐ Recommended for Service Accounts
29+
**Directory**: `py-oauth2-client-credentials/`
30+
31+
Use this for **robot/service account** authentication without user interaction.
32+
33+
**Best for:**
34+
- Server-to-server integrations
35+
- Automated scripts and workflows
36+
- Bulk data operations
37+
- Account-wide integrations
38+
- Background jobs and scheduled tasks
39+
40+
**Key Features:**
41+
- No user interaction required
42+
- Account-wide access
43+
- Simple authentication flow
44+
- Access tokens valid for 30 days
45+
46+
[View Example →](./py-oauth2-client-credentials)
47+
48+
---
49+
50+
### 3. OAuth1 (Legacy)
51+
**Directory**: `py-oauth1/`
52+
53+
**⚠️ Legacy Method** - Only use for maintaining existing integrations.
54+
55+
For new projects, use OAuth2 instead.
56+
57+
[View Example →](./py-oauth1)
58+
59+
---
60+
61+
## Quick Comparison
62+
63+
| Method | Use Case | User Interaction | Token Lifetime | Refresh Token |
64+
|--------|----------|------------------|----------------|---------------|
65+
| **OAuth2 Authorization Code** | User access | Required | 30 days | Yes (120 days) |
66+
| **OAuth2 Client Credentials** | Service accounts | Not required | 30 days | No (just request new) |
67+
| **OAuth1** | Legacy | Required | Permanent | No |
68+
69+
---
70+
71+
## Choosing the Right Authentication Method
72+
73+
### Use OAuth2 Authorization Code Flow when:
74+
✅ Your app needs to act on behalf of users
75+
✅ You need user-specific permissions
76+
✅ Building a web/mobile/desktop app
77+
✅ Users should control access to their data
78+
79+
### Use OAuth2 Client Credentials Flow when:
80+
✅ Building server-to-server integration
81+
✅ Need account-wide access (not user-specific)
82+
✅ Automating bulk operations
83+
✅ Running scheduled jobs
84+
✅ No user interaction is possible/desired
85+
86+
### Use OAuth1 only when:
87+
⚠️ Maintaining existing OAuth1 integration
88+
⚠️ Required by legacy systems
89+
90+
---
91+
92+
## Getting Started
93+
94+
### For User Authentication (OAuth2 Authorization Code)
95+
96+
1. **Register your application** in ProjectPlace
97+
- Go to Settings → Developer → Applications
98+
- Create new application
99+
- Note Client ID and Client Secret
100+
- Set Redirect URI
101+
102+
2. **Try the example**
103+
```bash
104+
cd py-oauth2-authorization-code
105+
pip install -r requirements.txt
106+
# Edit oauth2_authorization_code.py with your credentials
107+
python oauth2_authorization_code.py
108+
```
109+
110+
3. **Read the documentation**
111+
- [OAuth2 Authorization Code README](./py-oauth2-authorization-code/readme.md)
112+
- [API Documentation](https://api.projectplace.com/apidocs#articles/pageOAuth2.html)
113+
114+
### For Service Account Authentication (OAuth2 Client Credentials)
115+
116+
1. **Get robot credentials** from your administrator
117+
- Admin goes to Account Administration → Integration settings
118+
- Create robot user
119+
- Generate OAuth2 credentials
120+
- Receive Client ID and Client Secret
121+
122+
2. **Try the example**
123+
```bash
124+
cd py-oauth2-client-credentials
125+
pip install -r requirements.txt
126+
# Edit oauth2_client_credentials.py with your credentials
127+
python oauth2_client_credentials.py
128+
```
129+
130+
3. **Read the documentation**
131+
- [OAuth2 Client Credentials README](./py-oauth2-client-credentials/readme.md)
132+
- [Setup Guide](https://success.planview.com/Planview_ProjectPlace/Integrations/Integrate_with_Planview_Hub%2F%2FViz_(Beta))
133+
134+
---
135+
136+
## API Endpoints
137+
138+
All authentication methods work with the same API endpoints:
139+
140+
**Base URL**: `https://api.projectplace.com`
141+
142+
**Common Endpoints:**
143+
- `/1/user/me` - Get current user info
144+
- `/1/user/me/projects` - Get workspaces
145+
- `/1/projects/{id}/boards` - Get boards
146+
- `/1/boards/{id}/columns` - Get board columns
147+
- `/1/columns/{id}/cards` - Get cards
148+
- `/2/account/projects` - Get all account workspaces (requires appropriate permissions)
149+
150+
**Authorization Header:**
151+
```
152+
Authorization: Bearer {access_token}
153+
```
154+
155+
---
156+
157+
## Security Best Practices
158+
159+
### Never Commit Credentials
160+
❌ Don't commit `CLIENT_ID`, `CLIENT_SECRET`, or tokens to version control
161+
162+
✅ Use environment variables:
163+
```python
164+
import os
165+
CLIENT_ID = os.environ.get('PROJECTPLACE_CLIENT_ID')
166+
CLIENT_SECRET = os.environ.get('PROJECTPLACE_CLIENT_SECRET')
167+
```
168+
169+
### Always Use HTTPS
170+
❌ Never use HTTP endpoints
171+
✅ Always use HTTPS: `https://api.projectplace.com`
172+
173+
### Store Tokens Securely
174+
❌ Don't store tokens in plain text
175+
✅ Use encryption, secure vaults (AWS Secrets Manager, Azure Key Vault, etc.)
176+
177+
### Rotate Credentials Regularly
178+
✅ Generate new credentials periodically
179+
✅ Revoke old credentials after rotation
180+
181+
### Monitor API Usage
182+
✅ Log all API calls for audit
183+
✅ Set up alerts for unusual activity
184+
✅ Implement rate limiting in your application
185+
186+
---
187+
188+
## Additional Examples Using These Auth Methods
189+
190+
Once you understand authentication, check out these examples that use the auth methods:
191+
192+
- **py-download-document** - Download files using OAuth1
193+
- **py-upload-document** - Upload files
194+
- **py-enforce-column-name** - Bulk board updates using Client Credentials
195+
- **py-consume-odata** - Access OData feeds using Client Credentials
196+
- **py-board-webhooks** - Set up webhooks
197+
- **py-bulk-update-emails** - Bulk user operations
198+
199+
---
200+
201+
## Troubleshooting
202+
203+
### Common Issues
204+
205+
**"Invalid client" error**
206+
- Check your CLIENT_ID and CLIENT_SECRET
207+
- Ensure no extra spaces or characters
208+
- Verify credentials are for the correct environment
209+
210+
**"Redirect URI mismatch" (OAuth2 Authorization Code)**
211+
- Redirect URI in code must exactly match app settings
212+
- Include protocol (http:// or https://)
213+
- Match port number exactly
214+
215+
**"Insufficient permissions"**
216+
- For user auth: User must have appropriate access
217+
- For robot auth: Robot account must be granted access by admin
218+
- Check workspace/board-level permissions
219+
220+
**Tokens expire immediately**
221+
- Check your system clock is synchronized
222+
- Token expiration is based on timestamps
223+
224+
---
225+
226+
## API Documentation & Resources
227+
228+
### Official Documentation
229+
- [API Documentation](https://api.projectplace.com/apidocs)
230+
- [OAuth2 Guide](https://api.projectplace.com/apidocs#articles/pageOAuth2.html)
231+
- [Success Center](https://success.planview.com/Planview_ProjectPlace)
232+
233+
### Code Examples Repository
234+
- [GitHub: api-code-examples](https://github.com/Projectplace/api-code-examples)
235+
236+
### Support
237+
- Contact your Planview administrator for robot account setup
238+
- [Planview Support](https://success.planview.com)
239+
240+
---
241+
242+
## Contributing
243+
244+
Found an issue or have an improvement? Contributions welcome!
245+
246+
---
247+
248+
**Last Updated**: March 2026
249+
250+
**Disclaimer**: Planview provides these examples for instructional purposes. While you are welcome to use this
251+
code in any way you see fit, Planview does not accept any liability or responsibility for you choosing to do so.
252+
7.34 KB
Binary file not shown.

0 commit comments

Comments
 (0)