Skip to content

Commit 5d4d3bb

Browse files
committed
Merge branch 'hotfix/fix_readme'
2 parents 124d3f8 + af4ff6f commit 5d4d3bb

File tree

23 files changed

+1397
-712
lines changed

23 files changed

+1397
-712
lines changed

README.md

Lines changed: 21 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,31 @@
11
Web App Samples
22
========================
33
### Introduction
4-
These applications demonstrate Spark's cloud based 3D model storage, mesh preparation and 3D printing and can also provide an example of the Spark OAuth 2.0 procedure.
4+
These applications demonstrate Spark's cloud based 3D model storage, mesh preparation and 3D printing and can also provide an example of the Spark OAuth 2.0 implicit login procedure.
55

66
### Required setup before running the sample code
77
1. Clone the software repository (copy its files) to a folder on your web server.
88
2. If you have not already done so, define an app on the Spark Developers portal at https://spark.autodesk.com/developers/myApps.
9-
3. In the API Keys tab of the app registration, enter the fully qualified URL of the sample's plugins/login/login-callback.html file (do not use a relative path).
9+
3. In the API Keys tab of the app registration, enter the fully qualified URL of the sample's home page (do not use a relative path).
1010
4. Copy the app key for later use.
11-
5. If you are not using the advanced 3-legged auth flow, skip to step 8.
12-
6. Copy the app secret for later use.
13-
7. For the 3-legged authentication flow, you need to run a server. This repo is provided with a nodejs server. To run it you should:
14-
* Copy server/nodejs/config.example.js to server/nodejs/config.js and enter your app key and secret.
15-
* Install nodejs and then:
16-
```sh
17-
$ sudo npm -g install grunt-cli
18-
$ cd server/nodejs
19-
$ npm install
20-
$ node server.js
21-
```
22-
* Now you have a server running on port 3000. You can check it by going to http://your-server.com:3000.
23-
8. Initialize your app - see info in the "Quick Start" section.
24-
11+
5. Setup your app with your app key - see info in the "Quick Start" section.
2512

2613
### Quick Start
27-
* <b>Include the SDK library in your HTML page</b> just before closing the body section (`</body>`).
28-
29-
```HTML
30-
<script type="text/javascript" src="//code.spark.autodesk.com/autodesk-spark-sdk.min.js"></script>
31-
```
32-
33-
* After including the SDK library, the method ADSKSpark.Client.initialize() must be used to initialize and setup the SDK:<br>
34-
For the 3-legged authentication flow, the SDK requires that authentication API requests are called from a server. For example the guest token URL could be <i>http://example.com/guest_token</i>.
35-
36-
```JavaScript
37-
ADSKSpark.Client.initialize('<your app key>'); //<your app key> is a string containing your Spark app key, provided during registration.
38-
```
39-
40-
#### Sample code
41-
42-
```HTML
43-
<!DOCTYPE html>
44-
<html>
45-
<head>
46-
<title>Sample Code</title>
47-
<meta charset="utf-8">
48-
</head>
49-
<body>
50-
<div class="content">
51-
<a onclick="login()">Login</a>
52-
<br/>
53-
<a onclick="getGuestToken()">Get a guest token</a>
54-
</div>
55-
56-
<script type="text/javascript" src="//code.spark.autodesk.com/autodesk-spark-sdk.min.js"></script>
57-
<script>
58-
//Optional - Provide options
59-
var options = {
60-
isProduction:false, //(Optional - true/false) Whether we work in production or sandbox environment - default is sandbox
61-
redirectUri: 'http://localhost/webapp-samples/plugins/login/login-callback.html',// (Optional) The redirect URI for the auth service (i.e. http://example.com/callback), in cases where it is different than the one that was set for your app's Callback URL
62-
guestTokenUrl: '',//(Optional) The server URL to which guest token requests will be directed, for example http://example.com/guest_token.
63-
accessTokenUrl: '',//(Optional) The server URL to which access token requests will be directed, for example http://example.com/access_token.
64-
refreshTokenUrl: ''//(Optional) The server URL to which refresh access token requests will be directed.
65-
};
66-
67-
68-
ADSKSpark.Client.initialize('<your app key>',options);
69-
70-
/**
71-
* Open login window
72-
*/
73-
function login() {
74-
ADSKSpark.Client.openLoginWindow();
75-
}
76-
77-
function logout(){
78-
ADSKSpark.Client.logout();
79-
location.reload();
80-
}
81-
82-
function getGuestToken(){
83-
ADSKSpark.Client.getGuestToken().then(function(guestToken) {
84-
console.log('guest token: ',guestToken);
85-
});
86-
}
87-
88-
89-
if (ADSKSpark.Client.isAccessTokenValid()) {
90-
console.log('access token: ',ADSKSpark.Client.getAccessToken());
91-
ADSKSpark.Members.getMyProfile().then(function(response){
92-
console.log('Current logged in member is: ', response.member);
93-
});
94-
}
95-
96-
</script>
97-
</body>
98-
</html>
99-
```
100-
101-
A server side authentication process, fetching an access_token and guest_token, is required
102-
for your application to work. You can utilize one of the server implementations that are supplied in this repository.
14+
Copy the file "assets/scripts/config.example.js" to "assets/scripts/config.js" and supply these details:
15+
# **APP_KEY** - paste the app key from step 4 in the previous section
16+
# **REDIRECT_URI** - The redirect uri the Spark Auth flow will redirect your users after they will complete the login process.
17+
This repository is provided with a login callback html file that makes this task easy.
18+
The file is located in "plugins/login/login-callback.html" and you should set your REDIRECT_URI to http://example.com/your-app/plugins/login/login-callback.html
19+
(assumed the home page of your app is http://example.com/your-app)
20+
21+
### The contents of this repository
22+
This repository demonstrates sample usages of Spark APIs through these samples:
23+
1. 3D Models Healing Utility For Printing (healing-utility.html) - Assists in improving 3D printing success rates and minimize printing time with our extensive range of API print-preparation tools. Heal, fix and optimize your model for different materials, textures and file output types.
24+
2. 3D Models Printing Sample Application (sample-app-print.html) - Shows how to integrate an app with local and network 3D printers, desktop FDM printers and professional grade additive manufacturing systems.
25+
3. 3D Models Cloud Storage Application (sample-app-storage.html) - Uses Spark's cloud services to easily store 3D models and to create collaborative shared 3D creations.
26+
4. Public 3D Models Social Application (sample-app-gallery.html) - Demonstrates an online gallery, exhibits app-users' 3D image and digital creations and add social network functions, such as comments and likes.
27+
28+
### Using the SDK
29+
The samples provided in this repository utilize Spark's JavaScript SDK that is provided through [this link](https://code.spark.autodesk.com/autodesk-spark-sdk.min.js).
30+
31+
To run your own code with the SDK, reference the [JS SDK repository](https://github.com/spark3dp/spark-js-SDK).

assets/css/common.css

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,22 @@ i.stooltip span {
593593

594594
.si-upload-icon{
595595
background-position: -16px -82px;
596-
height: 42px;
596+
height: 44px;
597597
width:48px;
598598
}
599599

600+
.si-premede-files{
601+
background-position: -256px -299px;
602+
height: 44px;
603+
width: 33px;
604+
}
605+
606+
.si-drive-files{
607+
background-position: -11px -360px;
608+
height: 44px;
609+
width: 47px;
610+
}
611+
600612
.si-status-ok{
601613
background-position: -12px -14px;
602614
height: 18px;

assets/img/sprite_sampleapp.png

1.33 MB
Loading

assets/scripts/config.example.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
var APP_KEY = '<your app key>'; // Your app key
2-
var REDIRECT_URI = '<address of your callback.html file which is the same as your app\'s redirect url>';// Optional - The redirect URI you've set for your application
3-
var SERVER_URL = '<address of your server>';// The server url that implements guest,access and refresh token endpoints, without trailing slash(i.e. http://example.com)
4-
var ENVIRONMENT = 'sandbox'; // Use "sandbox" for the sandbox environment and "production" for production environment
2+
var REDIRECT_URI = '<address of app\'s home>/plugins/login/login-callback.html';// A redirect URI for your application
3+
var IS_PROD = false; // true for production, false for sandbox

assets/scripts/init.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
//Init the Spark Client - you may supply your personal config through the assets/scripts/config.js file
22
var APP_KEY = APP_KEY || '',
3-
GUEST_TOKEN_URL = SERVER_URL ? SERVER_URL + '/guest_token' : 'http://localhost:3000/guest_token',
4-
ACCESS_TOKEN_URL = SERVER_URL ? SERVER_URL + '/access_token' : 'http://localhost:3000/access_token',
5-
REFRESH_TOKEN_URL = SERVER_URL ? SERVER_URL + '/refresh_token' : 'http://localhost:3000/refresh_token',
6-
REDIRECT_URI = REDIRECT_URI || '';
7-
8-
var isProd = (ENVIRONMENT == "sandbox") ? false : true;
3+
REDIRECT_URI = REDIRECT_URI || '',
4+
IS_PROD = IS_PROD || false;
95

106
var options = {
11-
isProduction: isProd,
12-
redirectUri: REDIRECT_URI,
13-
guestTokenUrl: GUEST_TOKEN_URL,
14-
accessTokenUrl: ACCESS_TOKEN_URL,
15-
refreshTokenUrl: REFRESH_TOKEN_URL
7+
isProduction: IS_PROD,
8+
redirectUri: REDIRECT_URI
169
};
1710

1811
ADSKSpark.Client.initialize(APP_KEY, options);

examples/auth/access-token.html

Lines changed: 0 additions & 108 deletions
This file was deleted.

examples/auth/guest-token.html

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)