Skip to content

Commit 97b4e85

Browse files
committed
make changes to README
1 parent b99a56e commit 97b4e85

File tree

2 files changed

+96
-5
lines changed

2 files changed

+96
-5
lines changed

oauth-workflow-sample/README.md

Lines changed: 95 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,98 @@
1-
# Starter Photoshop Plugin (Vanilla)
1+
# How to Integrate with OAuth
22

3-
This starter plugin is a good place to get started when developing for Photoshop. It does not rely on any frameworks or build steps -- hence the name "Vanilla".
3+
This tutorial will show you how to implement the OAuth workflow in an XD plugin, using the Dropbox API as an example.
44

5-
## Loading in Photoshop
5+
> **info**
6+
> Auth workflows are necessarily complex, so this tutorial will be on the longer side and make use of some advanced concepts. Please read the each section carefully, especially the Prerequisites and Configuration sections.
67
7-
You can load this plugin directly in Photoshop by using the UXP Developer Tools application. Once started, click "Add Plugin...", and navigate to the "manifest.json" file in this folder. Then click the ••• button next to the corresponding entry in the developer tools and click "Load". Switch over to Photoshop, and the plugin's panel will be running.
8+
## Prerequisites
9+
10+
- Basic knowledge of HTML, CSS, and JavaScript.
11+
- [Quick Start Tutorial](/develop/tutorials/quick-start/)
12+
- [Debugging Tutorial](/develop/tutorials/debugging/)
13+
- Familiarity with your OS's command line application
14+
- Familiarity with [OAuth](https://oauth.net/2/)
15+
- [A registered app on Dropbox](https://www.dropbox.com/developers/apps/create) with the following settings:
16+
17+
1. Choose "Dropbox API"
18+
1. Choose "Full Dropbox" for the access type
19+
20+
## Technology Used
21+
22+
1. [Install required] [Node.js](https://nodejs.org/en/) and the [`npm` package manager](https://www.npmjs.com)
23+
1. [OAuth](https://oauth.net/2/)
24+
1. [Dropbox API](https://www.dropbox.com/developers/documentation/http/overview)
25+
26+
## Overview of the OAuth workflow
27+
28+
There are three parts of this workflow:
29+
30+
- Your Photoshop plugin
31+
- Your server endpoints (for this development example, we'll create a local Node.js server)
32+
- The service providers OAuth endpoints (for this example, the Dropbox API)
33+
34+
The high-level workflow is as follows:
35+
36+
1. The Photoshop plugin pings the server to get the session ID
37+
1. The server returns a unique ID for the user's Photoshop session
38+
1. Plugin opens a tab in user's default browser with a URL pointing to an endpoint on the server
39+
1. The server handles the entire OAuth code grant workflow
40+
1. The user gives necessary permissions to the plugin
41+
1. The server saves the access token paired with the session ID
42+
1. The plugin polls the server to check if the access token is available for the session ID. If the token is available, the server sends the access token back
43+
1. The plugin uses the access token to make API calls to the service API
44+
45+
## Configuration
46+
47+
The following steps will help you get the sample code from our GitHub repo up and running.
48+
49+
### 1. Install Node.js packages
50+
51+
Inside the sample repo's `server` folder, there is a `package.json` file that contains a list of dependencies. Run the following command from the top level directory of the repo to install the dependencies:
52+
53+
```bash
54+
$ cd server
55+
$ npm install
56+
```
57+
58+
### 2. Set your API credentials and public URL
59+
60+
Enter the required credentials in `public/config.js`. You'll need:
61+
62+
- Your Dropbox API key
63+
- Your Dropbox API secret
64+
- Your `ngrok` public URL
65+
66+
```js
67+
const dropboxApiKey = "YOUR-DROPBOX-API-KEY";
68+
const dropboxApiSecret = "YOUR-DROPBOX-SECRET";
69+
const publicUrl = "http://localhost:8000";
70+
71+
try {
72+
if (module) {
73+
module.exports = {
74+
dropboxApiKey: dropboxApiKey,
75+
dropboxApiSecret: dropboxApiSecret,
76+
publicUrl: publicUrl,
77+
};
78+
}
79+
} catch (err) {
80+
console.log(err);
81+
}
82+
```
83+
84+
Our server will make use of these settings in a later step.
85+
86+
### 3. Start the server
87+
88+
After completing the configuration steps, start the server from the `server` folder:
89+
90+
```
91+
$ npm start
92+
```
93+
94+
Now you have a running server with an HTTPS endpoint and your Dropbox credentials ready to go.
95+
96+
### 4. Running the plugin
97+
98+
Just load up the plugin in Photoshop and click on **Connect OAuth** to get the plugin running.

oauth-workflow-sample/server/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ app.get('/callback', function (req, res) {
5858

5959
/* Simulating writing to a database */
6060
requestIds[requestId]["accessToken"] = response.access_token;
61-
res.json({ 'response': 'Authentication successful. You can close this tab' });
61+
res.send('Authentication successful. You can close this tab');
6262
})
6363
.catch(function (error) {
6464
res.json({ 'response': 'Log in failed!' });

0 commit comments

Comments
 (0)