Package org.vrspace.server.api
Class SketchfabController
- java.lang.Object
-
- org.vrspace.server.api.ApiBase
-
- org.vrspace.server.api.SketchfabController
-
@RestController @RequestMapping("/vrspace/api/sketchfab") public class SketchfabController extends ApiBase
You want to download free content from sketchfab, you have to be OAuth2 authorised with them. Once done, the server uses the same credentials for all further communication with sketchfab, until restart. This is completely different than Oauth2 used to authenticate with vrspace server, i.e. this is how vrspace server authenticates with sketchfab. Credentials are kept in memory only, but the content is cached locally, under content directory hierarchy, where sketchfab content categories are used for subdirectory name. Content metadata is stored in the database, as GltfModel entities.- Author:
- joe
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SketchfabController.AuthResponse
static class
SketchfabController.DownloadResponse
static class
SketchfabController.FileInfo
static class
SketchfabController.LoginResponse
-
Constructor Summary
Constructors Constructor Description SketchfabController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.springframework.http.ResponseEntity<String>
callback(String code)
Sketchfab oauth2 callback, as explained in https://sketchfab.com/developers/oauth#implement-auth-code Uses code provided by client to authorise at sketchfab, and returns 302 redirect to the saved referrer.org.springframework.http.ResponseEntity<GltfModel>
download(String uid, javax.servlet.http.HttpServletRequest request)
Sketchfab download, as explained in https://sketchfab.com/developers/download-api/downloading-models Requires successful authentication, returns 401 unauthorised unless the server is authorised with sketchfab (token exists).SketchfabController.LoginResponse
login(javax.servlet.http.HttpServletRequest request)
Start of the login sequence.
-
-
-
Field Detail
-
PATH
public static final String PATH
- See Also:
- Constant Field Values
-
-
Method Detail
-
login
@GetMapping("/login") public SketchfabController.LoginResponse login(javax.servlet.http.HttpServletRequest request)
Start of the login sequence. Returns the sketchfab login url, containing client id and redirect url. Client is then expected to open that url and authorise there. Saves the referrer for later use in callback.
-
callback
@GetMapping("/oauth2") public org.springframework.http.ResponseEntity<String> callback(String code)
Sketchfab oauth2 callback, as explained in https://sketchfab.com/developers/oauth#implement-auth-code Uses code provided by client to authorise at sketchfab, and returns 302 redirect to the saved referrer.- Parameters:
code
- provided to the client by sketchfab- Returns:
-
download
@GetMapping("/download") public org.springframework.http.ResponseEntity<GltfModel> download(String uid, javax.servlet.http.HttpServletRequest request)
Sketchfab download, as explained in https://sketchfab.com/developers/download-api/downloading-models Requires successful authentication, returns 401 unauthorised unless the server is authorised with sketchfab (token exists). In that case, client is expected to attempt to login.- Parameters:
uid
- unique id of the modelrequest
- original request, referrer is saved for later use in case the authentication fails- Returns:
-
-