I am having problems getting Autodesk Forge API to accept my files into a photoscene. The error message I get from the API call is:
{"developerMessage":"Access token provided is invalid or expired.", "moreInfo": "https://forge.autodesk.com/en/docs/oauth/v2/developers_guide/error_handling/", "errorCode": ""}
This error confuses me, as it comes immediately after I have just used this same forge_access_token successfully to create the photoscene I am adding these files to.
And the ""errorCode": "" section provides me no clues about what is wrong.
Here is the code sequence in my program:
- Get the forge_access_token,
- Create the photoscene, and
- Add image files to the photoscene.
1. I'm successfully getting an access_token with this code:
# Request for a 2-legged OAuth access token
json=`curl -s $FORGE_URL/authentication/v1/authenticate \
-d client_id=$CLIENT_ID\
-d client_secret=$CLIENT_SECRET\
-d grant_type=client_credentials\
-d scope=data:read+data:write
`
forge_access_token=`echo $json | jq -r .access_token`
echo "forge_access_token: $forge_access_token"
2. I then use the returned forge_access_token in the following code to successfully request a new photosceneid:
json=`curl -s $FORGE_URL/photo-to-3d/v1/photoscene \
-X 'POST' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $forge_access_token" \
-d "scenename=$scan_id" \
-d 'scenetype=object' \
-d 'format=obj,rcm'
`
# echo $json
photosceneid=`echo $json | jq -r .Photoscene.photosceneid`
echo "Created Photoscene: $photosceneid"
3. But when I call this code to add image files to this new photoscene, it fails to add them:
JPG_FILES=$scan_dir/*.jpg
i=0
for image_file in $JPG_FILES
do
file_name=`basename $image_file`
json=`curl -s $FORGE_URL/photo-to-3d/v1/file \
-H 'Authorization: Bearer $forge_access_token' \
-d 'photosceneid=$photosceneid' \
-d 'type=image' \
-d 'file[$i]=$image_file'
`
i=$((i+1))
I am failing with this error message:
{"developerMessage":"Access token provided is invalid or expired.", "moreInfo": "https://forge.autodesk.com/en/docs/oauth/v2/developers_guide/error_handling/", "errorCode": ""}
Have any other Forge Reality Capture API users seen this? How did you solve it?