Closed sherbertiConstruct closed 5 years ago
do you have the localhost server running? Note you need to launch both.
I'm getting the same error (Cannot call /api/forge/session/isvalid). I have tried setting my solution to start both projects and I have right clicked on "cloud" and started an instance, then right clicked on "desktop" and started an instance. Same error each time. I've changed the host to be non secure (http) and that still doesn't work. How do you start the localhost server?
Snipped from my web.config:
Thanks, Joe
It appears that this line:
sessionId = Encoding.UTF8.GetString(System.Web.Security.MachineKey.Unprotect(Convert.FromBase64String(sessionId)));
in HeaderUtils.cs is causing the error. sessionId is a string before it runs through here but is an empty string when this line executes. I've tried commenting out this line but then I get a different RESTAPI response error.
Can you please help with this? Thanks, Joe
Just tried the sample, works fine, I would suggest you clean the MongoDB database, maybe some data is corrupted and causing this. The sessionId
enters this method as NULL, then is set to EMPTY, then the correct value from the cookie header.
I have upgraded the package versions, there is a change on how CefSharp handles cookies, see this line.
I have the same problem. The login to Autocad is fine, then it fails on session/isvalid. I have noted that in HeaderUtils.cs, the GetSessionLocalIDs method, the sessionId is NULL, EMPTY and correct value from cookie, however the unencrypt call always sets sessionId back to empty string. Skipping the unencryption still gives the same error
EDIT: I resolved my problem above, it was due to a hardcoded database name in cloud\App_Code\Database.cs. It must match the database name in your MongoDB! I guess you can read it as the last part of the connection string. Now it works perfectly, thanks!
This change will read the database name from the connection string:
private static IMongoDatabase Database
{
get
{
//Read database as last item on the connection string
string[] parts = ConfigVariables.OAUTH_DATABASE.Split('/');
string db = parts.Last();
if (_database == null) _database = Client.GetDatabase(db);
return _database;
}
}
thanks for the suggestion, @OMH2Share, will add that on the code (it's better 😄 )
fixed
This seems to be the error I came up against. It was caused by two things:
(The returned database entry was just the first entry found, with an expired DateTime. Getting a refresh token failed as it was for an access token that had long expired. This caused a status 500 return value.)
The fix is to change
var docs = await users.FindAsync(new BsonDocument());
to
var docs = await users.Find(filter).ToListAsync();
thanks @WspDev, makes sense
Thank you @augustogoncalves . Did you intend to await await on the fix?
such a silly mistake here... thanks! (push the wrong file)
After I have successfully logged in I get this error.
System.Exception: 'Cannot call /api/forge/session/isvalid'