https://github.com/apprentice3d/aws-lambda-token-fetcher
Golang AWS Lambda function used to get viewable:read 2-legged tokens.
https://github.com/apprentice3d/aws-lambda-token-fetcher
Last synced: 8 months ago
JSON representation
Golang AWS Lambda function used to get viewable:read 2-legged tokens.
- Host: GitHub
- URL: https://github.com/apprentice3d/aws-lambda-token-fetcher
- Owner: apprentice3d
- License: mit
- Created: 2018-08-01T16:28:34.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-02T12:53:07.000Z (over 7 years ago)
- Last Synced: 2025-04-13T10:02:19.657Z (10 months ago)
- Language: Shell
- Size: 174 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## AWS Lambda token fetcher
Small lambda written in Golang and used to get `viewables:read` 2-legged tokens, which in conjunction with AWS API Gateway creates the minimal backend needed for serving to Forge Viewer the access tokens.
### Setup
1. create a deployment package following the [AWS guide](https://docs.aws.amazon.com/lambda/latest/dg/lambda-go-how-to-create-deployment-package.html) or create a new lambda through AWS portal and upload the zip file (either prepared by you or downloaded from [releases](https://github.com/apprentice3d/aws-lambda-token-fetcher/releases))(A).
2. Set the environment variables with your Autodesk Forge credentials (as shown in bellow at B).

3. Through AWS portal, in API Gateway, create a new API, set the integration type as lambda and specify the AWS lambda created at step 1.

4. Use the endpoint created by the API Gateway, in your apps to get the `viewables:read` tokens, used by viewer to display your models:
```javascript
let options = {
env: 'AutodeskProduction',
getAccessToken: (onGetAccessToken) => {
fetch('https://9irt90dm6j.execute-api.us-east-1.amazonaws.com/prod')
.then(response => response.json())
.then(data => {
let accessToken = data["access_token"];
let expireTimeSeconds = data["expires_in"];
onGetAccessToken(accessToken, expireTimeSeconds);
})
}
};
```