"User is unauthorized" error with sample web viewer app - bentley-itwin

I'm following the instructions here: https://www.itwinjs.org/learning/tutorials/develop-web-viewer/ to create a sample web viewer app. The doc says to update variable IMJS_CONTEXT_ID which is not in the .env file and doesn't appear with "Show IDs" for my iModel (I have created a github issue for the doc already). I've tried updating the variable IMJS_ITWIN_ID instead with the "iTwin ID" from my iModel. When I start the app I get an error page "An Error Has Occurred: The user is unauthorized. Please provide valid authentication credentials". I have checked the variables IMJS_AUTH_CLIENT_CLIENT_ID, IMJS_AUTH_CLIENT_REDIRECT_URI, IMJS_AUTH_CLIENT_SCOPES, IMJS_ITWIN_ID, IMJS_IMODEL_ID and all appear to be correct. Is there something else I need to configure?

Sorry, the tutorial you're referring to is a bit outdated now. Have you taken a look at https://developer.bentley.com/tutorials/web-application-quick-start/?
In the new #itwin/web-viewer-react templates we renamed IMJS_CONTEXT_ID to IMJS_ITWIN_ID. We also made some changes to the required scopes, you'll need namely imodelaccess:read, imodels:read, and realitydata:read. Please make sure your auth client has the above scopes and you have access to the model. If you still have trouble, feel free to continue the discussion over at https://github.com/iTwin/itwinjs-core/discussions

Related

Directus - AWS S3 Upload - error message: Cannot set property 'value' of undefined

I just set up directus with s3 storage like this: https://docs.directus.io/extensions/storage-adapters.html#core-adapters
It seems to be working: but there is one issue:
When I upload an image, it gives me an error: Cannot set property "value" of undefined
But when I refresh the page, all is done and it seems to be fine. The files are on s3 and I can see it in my admin panel. But the error message and the need to refresh the page sucks - especially when it comes to give it to my clients.
Is it possible that this could be a bug in the source code of directus?
But when its like that, why I am the only person having this issue ... ?
Here are my config details:
It could be a bug... perhaps related to a migrations issue (which would be why it's not seen by more people). You could open a ticket on GitHub and the developers will check it out. Just try to make sure it's not a config issue first. :)

Dropbox getTemporaryLinks API errors description

I received an email from Dropbox states from middle of october get temporary links api will returns an email_not_verified error in case user not verified her email address, so far so good.
I'm able to get the response body from the doc https://www.dropbox.com/developers/documentation/http/documentation#files-get_temporary_link
Since I'm using dropbox java sdk and I'm used to code test first, I was trying to simulate the scenario, but having the json inside the http response, I've an error parsing the json inside dbx library. So I tried changing the status code and, having 409 I got com.dropbox.core.v2.files.GetTemporaryLinkErrorException: Exception in 2/files/get_temporary_link: "other"
but it is not enough, since I need to manage the scenario.. Can someone help me understanding what I can check in the code but first of all, what is the response I've to simulate in my unit test?
Thanks in advance
The other error case indicates that it's an error that the SDK you're using does not recognize. The GetTemporaryLinkError.email_not_verified error is relatively new, so you'll need to make sure you're using a recent enough version of the SDK to be able to identify it. For the GetTemporaryLinkError.email_not_verified error, that is v3.1.0 or later of the Dropbox Java SDK. (It's best to just get the latest anyway, which is currently v3.1.1.)
If you're are using an updated version of the SDK, it's also possible you're just not setting valid JSON for the GetTemporaryLinkError.email_not_verified error case when you're trying to simulate this. You can find the valid JSON for this error case in the /2/files/get_temporary_link documentation. Make sure you copy that as shown there if you're trying to simulate this.
Lastly, to actually catch that error with the Dropbox Java SDK, you'll want to catch GetTemporaryLinkErrorException thrown by getTemporaryLink. To check for the specific case, check the GetTemporaryLinkErrorException.errorValue. The GetTemporaryLinkError.isEmailNotVerified will return true for the unverified email case.

How to do display security check authorization?

I am working around permission model in my project so when a particular user is not authorized then a screen is displayed depicting that the a user is not authorized to access the screen (which according to my best knowledge comes from a ArtifactExecutionFacadeImpl.groovy).
Is there any possible way to show that catch that exception and show it in a message.
So could you please suggest a way to do the same.
The current code returns a 401 (unauthorized) error when the authz fails (see MoquiServlet.groovy:68). You can display a custom screen with a code change instead of just returning the 401 error, or you can modify the web.xml file to specify a page to render for that particular response code (just like you can as part of the Servlet spec for any response code through the web.xml file).
Rendering a configured screen would be a useful enhancement to the framework (would be much cleaner and more flexible than either of the approaches mentioned above). I'll think on this and may work on it in the near future. If you or anyone end up building this, feel free to send over a pull request on GitHub and I'll take a look at it.

Google+ .Net API - Getting Authenticated and retrieving profile

I'm trying to get a users profile information for google+ via the .NET API but am having trouble.
Does anyone know if they have changed how the special ID "me" works?
In the documentation it says this can be used as a special ID to get the currently authenticated users information however this throws a 404 from both the API in my code and on Google's own test page https://developers.google.com/+/api/latest/people/get. I was logged in when trying this.
Does anyone know how to get the user ID as I would happily use that instead of me but it isn't returned after the user authenticates as far as I can see (just an authcode)?
I also tried using user IDs returned when using the standard .net Oauth stuff but it isn't the correct ID, I assume it is for something else.
As for my method of getting to this stage, I first downloaded the example files here: http://code.google.com/p/google-api-dotnet-client/wiki/GettingStarted
They don't have a plus example so I took the Tasks.ASP.NET.SimpleOAuth2 example and swapped out tasks (which worked fine) for the plus equivalent.
I also tried rolling this into my own project.
Neither worked. I get the user forwarded to Google where they give me access fine and then when I return they are authenticated successfully as far as I can see, however when I call service.People.Get("me") it returns a 404.
If anyone could help with the above questions (using me, or gettign the user ID) I would appreciate it.
To the moderator who closed the initial version of this question, I have tried to make this as direct a question as possible so please don't close it. This is a legitimate question I would really like help getting to he bottom of.
This is now out of date given recent platform updates. Although the plus.me scope still exists and this code will work, you should be using the plus.login scope for retrieving profile data in C#. For a great way to get started with retrieving and rendering profile information, please start from the Google+ C# quick start available here:
https://developers.google.com/+/quickstart/csharp
First off, the 'me' id still works and is unchanged. The way that it works is:
You authenticate the user using a standard OAUTH2 flow
You use the library to perform a People.get with the special value 'me'
The 404 error code is a little troubling, this means that the client isn't finding the endpoint. To debug this, you might want to use a packet sniffer like fiddler to see what the actual URL it's querying is.
Anyways, how about some C# code. The following example shows how to use the plus service to get the currently authenticated user (assuming you have authenticated someone). What's different from your snippet is that you need to form a get request for the API call, then run fetch on the get request. I've included the following example, for getting 'me', and the following code works:
var auth = CreateAuthenticator();
plusService = new PlusService(auth);
if (plusService != null)
{
PeopleResource.GetRequest prgr = plusService.People.Get("me");
Person me = prgr.Fetch();
}
All of the configuration of the server and getting a client working is pretty hard and pasting all of the code here would be less helpful than just giving you a sample.
And so... I have written a sample application that demonstrates how to do this and also includes a wrapper that makes it easier to develop using the Google+ API in C#. Grab it here:
Google+ C# Server-Side demo and library
Seems you need to use:
Person test = service.People.Get("me").Fetch();
and not
req = service.People.Get("me");
Person test = req.Fetch();
Even though they seem to be identical the first works and the second doesn't.
Still not sure why google's own page doesn't work though. Now to find out how to add things to the scope like birthday.

Express Checkout error message: "Security header is not valid"

I'm implementing Express Checkout in PayPal.
I have no problem with the first two steps, SetExpressCheckout and GetExpressCheckout. But when I use DoExpressCheckout, I encounter the error "Security header is not valid".
The API credentials are the same!
I've fixed it by changing the $environment to live in DoExpressCheckout. (The difference $environment makes is that it'll use https://api.sandbox.paypal.com/nvp/ instead of https://api-3t.$environment.paypal.com/nvp)
But why?
Is there something wrong with https://api-3t.$environment.paypal.com/nvp?
https://api-3t.sandbox.paypal.com/nvp requires different user-accounts than what https://api-3t.paypal.com/nvp requires.
The sandbox accounts can be activated at developer.paypal.com
I had the same error being thrown for the live environment. For me, it turned out there was a trailing space at the end of my API username.... I removed the space and it worked fine.... I'd pasted them into a config file straight from PayPal and must've copied a blank there as well... so if this happens to you, check for trailing spaces! This would've been obvious if the username was hardcoded in a string, but wasn't because it was in a java properties file.
note that you'll also get this error if your credentials are wrong (ie bad username, password or signature). I just had the same issue happen when I pasted in my info to a config file, and had extra characters at the end of my signature by mistake.
He may not grant permission for checkout. Refer to this article, apparently down for now but still available here.