Hello.js MSAL usage in Office Web Add-in Issue - msal

I'm using the hello.js for MSAL Microsoft Active Directory Library to authenticate a user for a Word Office web add-in. It works great up to returning to my original window.
Here's my basic setup
Call a dialog pop up in Word web add-in then in that popup use the loginRedirect promise function.
Works great! I authenticate using my APPid and tenant ID.
One observation is it requires a HTTPS reply redirect URL!!!!
However when it returns after successful login I get few errors in my dev tool console
First it cannot find an html element and it returns null or undefined
Second I saw a Unable to get property 'then' of undefined or null reference when I clicked signIn() and ran the loginRedirect function
This hello.js library is from the https://github.com/AzureAD/microsoft-authentication-library-for-js
Please let me know why I'm getting null or undefined when using var divWelcome = document.getElementById('WelcomeMessage'); ?

I solved this by restructuring my code and isolating the issue. There was an error that was preventing full processing. The MSAL Hello.js library works very well even for Office Add-ins!

Related

vbscript gives different error in different browser

The functionality of the code is that once the upload button is clicked a text file should be created in the given location.
With the current code I am getting uncaught referenceerror is not defined at htmlinputelement.onclick error in other browsers and ' error 429 activex component can't create object' in internet Explorer.
Please help Me, my machine is windows 10
uncaught referenceerror is not defined at htmlinputelement.onclick error in other browsers
Only Internet Explorer supports VBScript, so in other browsers the <script language="VBScript"> is ignored. This means the function isn't created. This means it isn't defined when you try to call it.
error 429 activex component can't create object' in internet Explorer
Here the function is created, but it doesn't work.
Internet Explorer doesn't allow webpages to use ActiveX to write to the user's hard disk. It would be a serious security problem.
You can only use that component in non-webpage contexts (such as in a Classic ASP application).
The closest you can come is to create a URL with the data embedded in it that the user can download.

Bot Framework emulator not posting to localhost after renaming my solution (500 error)

I created a Web App Bot in Azure with a basic template, downloaded the files and tested it with no problems on localhost with the Bot Framework Emulator.
However, once I renamed the solution/project/namespaces from the default Microsoft.Bot.Samples.SimpleEchoBot to MyBotName, the Bot Emulator received 500 - Internal Server Error.
The solution builds and runs, and setting a breakpoint in the MessagesController shows that the Post method is never reached.
How do I fix this?
A GET request to localhost:[PORT]/api/messages (open that url in the browser) reveals the error message Multiple types were found that match the controller named 'messages'. It was somehow finding both the old messages controller (Microsoft.Bot.Samples.SimpleEchoBot.MessagesController) and the new one (MyBotName.MessagesController).
Solution: delete the bin/ folder and re-build/run the project.

Google picker does not work without filter being applied for some users

we have an integrated with google picker(read-only scope,Docs view) it use to work fine but recently some users are getting blank screens as soon as the pop up shows but when they select some filter everything starts working fine after that no problems.
using developer tools i see all apis returning 200 for that first request
but there were no docs in response(i believe this is the api responsible for bringing docs in picker 'https://docs.google.com/picker/pvr')
when there are no docs returned in above api google is calling another api i assume it is to log error's probably(//docs.google.com/picker/ohnoes)
this api has following error params in it
&error=Cached and requested query mismatch
&line=Not available
&viewToken=["all",null,{"query":null}]
&ms=97
&transferDocs=false
&numErrors=1
has anybody else faced the similar problem
what do error "Cached and requested query mismatch" means in context of drive docs
Fyi - most accounts facing this problem seems like are of company domain for ex "jondoe#company.org"(this is a google account with company domain)
Filters Image
Thanks for your help.
not sure but looks like issue was may be related to google bug
https://issuetracker.google.com/issues/64825685
for me the code that was not working was:
addView(google.picker.ViewId.DOCS)
replaced this code with below code which works as expected
var view = new google.picker.DocsView();
view.setIncludeFolders(true).setOwnedByMe(true).setParent('root');
addView(view).

Google API authentication: Not valid origin for the client

When making an auth request to the Google API (gapi), it's returning false on the checkOrigin.
I have removed any client id's or anything that would link directly to my account and replaced it with a regex indicating what the data is for reference.
Url: https://accounts.google.com/o/oauth2/iframerpc?action=checkOrigin&origin=https%3A%2F%2Flocal.tools&client_id=(\d{21})
My origin url is a local url, which is https://local.tools
Result: {valid: false}
I'm using the example found here without deviation (except for replacing clientid with my 21 digit clientid): https://ga-dev-tools.appspot.com/embed-api/third-party-visualizations/
The items I'm trying to display show up nicely on the demo site, but aren't getting past the Not valid origin for the client error on my local.tools site.
Clear your browser cache. Started getting this error in Chrome and then I created a new client id and was still getting the issue. Opened firefox and it worked, so I cleared the cache on Chrome and it started working.
I received the same console error message when working with this example: https://developers.google.com/analytics/devguides/reporting/embed/v1/getting-started
The documentation says not to overlook two critical steps ("As you go through the instructions, it's important that you not overlook these two critical steps:
Enable the Analytics API [&] Set the correct origins"), but does not clearly state WHERE to set the correct origins.
Since the client ID I had was not working, I created a new project and a new client ID. The new project may not have been necessary, but I'm retaining (and using) it.
Here's what worked:
Create a new project
Add and Enable the Analytics API
Create a new credential - ensure that it is an OAUTH credential (scroll to the bottom of this page for instructions https://developers.google.com/api-client-library/javascript/start/start-js#Setup).
During creation of the credentials, you will see a section called "Restrictions
Enter JavaScript origins, redirect URIs, or both". This is where you can enter your origins.
Save and copy your client ID (and secret).
My script worked after I created the new OAUTH credential, assigned the origin, and used the newly generated client ID following this process.
try clear caches and then hard reload, i had same error but when i tried to run on incognito browser in chrome it worked.
Key Point: Add both http://localhost and http://localhost:port_number to the Authorized JavaScript origins box for local tests or development.
Credentials do not work if API is not enabled. In my case the next steps were needed:
Go to https://console.developers.google.com/apis/library
Enter 'People'
From the result choose 'Google People API'
Click 'Enable'
Creating new oauth credentials worked for me
You probably use Client ID like this: <CLIENT_ID>.apps.google.com
Make sure your client ID is without ".apps.google.com"
For me - I just went here:
https://console.developers.google.com/apis/credentials
Then chose the right project; then choose the credential with the same ID shown in your console error message. When editing the credentials you can add multiple origins to the white list.
After updated Authorized JavaScript origins browser still caching old data, so I need to Empty cache and hard reload then it works
1. Change Authorized origins
2. Open Dev Tool (F12) then right-click into reload button
Clearing the cache on chrome works!
Please find the steps below to clear the cache.
Open dev tools (Right-click on the page and select inspect/ press F12)
Right-click on the chrome reload button while the dev tool is opened. (You will find the option to clear the cache and reload the site)
clearing the cache works for me.
for React developers try to restart the project otherwise it will show the same error again and again.
It was a referrer-policy problem.
This has been such a pain for a long time to me too...
Found the issue, my website instance had a referrer policy set to
no-referrer. After setting it to no-referrer-when-downgrade, the One
Tap prompt showed up as expected.
https://stackoverflow.com/a/63039142/15565029
If you are using Django, SECURE_REFERRER_POLICY is 'same-origin' by default. Change it by adding the below code in your settings file.
# settings.py
SECURE_REFERRER_POLICY = 'no-referrer-when-downgrade'
https://docs.djangoproject.com/en/3.2/ref/settings/#std:setting-SECURE_REFERRER_POLICY
Similar to few answers at above but with screenshots. If you created project for Firebase, may also use the same steps to configure at Google Cloud Platform console.
Select the project at https://console.cloud.google.com/
Navigate to Credentials
Click Edit button for the related OAuth 2.0 Client ID
Add URI into Authorized JavaScript origins
Don't forget to Save
That worked for me after trying for an hour:
On https://console.cloud.google.com/apis/credentials :
Edit Client Outh (mine was: Web Client (Auto Created by Google Service), which was created by my Firebase Web Project)
Enter JavaScript Origin for the Client ID (mine was: localhost:NNNN)
and don't forget to Save.
Try google login for half an hour: didn't work
Enabled Google Analytics as suggested above
Empty Chrome cache and hard reload as suggested above
Try google login for half an hour: didn't work
Sign Out from https://console.cloud.google.com, and sign in again
Empty Chrome cache and hard reload
Now it worked
I don't know which one of the above fixed the problem.
May be it was just a matter of time for cloud.google to
recognize my new JavaScript Origin.
I got the error because of Allow-Control-Allow-Origin: * browser extension.
Trying on a different browser(chrome) worked for me and clearing cache on firefox cleared the issue.
(PS: Not add the hosting URIs to Authorized JavaScript origins in API credentials would give you Error:redirect_uri_mismatch)
I was getting the same error but tried publishing my app and now it shows as below:

Microsoft.SharePoint.WebControls.SPRibbon not Working In Sharepoint SandBox Solution?

I wanna create Contextual Tab using Webpart In Sandbox Solution..that time I am getting Error as below When i am added Custom-Webpart :
Web Part Error: Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: An unexpected error has occurred.
In My Webpart's Code
Microsoft.SharePoint.WebControls.SPRibbon.GetCurrent(this.Page).MakeTabAvailable("MyProject.Ribbon.HelloTab");
Is there another way to Solution To create Custom Ribbon Tab?
Altering the ribbon is not permitted from within the sandbox. You have to options available to you.
Make your solution a farm solution (thereby giving it the necessary permissions)
Use a sandbox proxy the perform the steps on the ribbon (see MSDN)

Resources