Comments (3)
@ostorefice Thanks 👍
There's no way to get user name in this library as we don't control the scope/API implementations of each of the Auth providers. It would add additional maintenance costs and hence I suggest using the Graph API to get that information with the token you obtained.
See more info here: https://developer.microsoft.com/en-us/graph/
Here's a sample on how to use Office Helpers with graph: https://github.com/microsoftgraph/javascript-officeuifabric-peoplepicker-sample/blob/master/PeoplePicker.html#L163
from office-js-helpers.
If, by username you mean the UPN then this is one of the returned values (I'm using the /me endpoint when querying msft graph)
I'm using react, but the following code is probably quite obvious, and provides me with the UPN (the token's scope used for this request is https://graph.microsoft.com/User.Read):
export function getMicrosoftUserProfile(token){
return function(dispatch){
request
.get(`${constants.MSFT_DATA_API}/me/`)
.set('Accept', 'application/json')
.set('Authorization', `Bearer ${token.access_token}`)
.then(
res => {
if (res.status >= 200 && res.status < 300) {
dispatch(setUserInformation(res.body))
console.log(res.body)
}
}
)
.catch((err) => {
console.log(err.status + ': ' + err.response)
})
}
}
returned values:
businessPhones : []
displayName : "Marvin Martian"
givenName : "Marvin"
id : "4b60d56e-4edd-4b4c-873a-f0e6d1112345"
jobTitle : "Chief Technology Officer"
mail : "[email protected]"
mobilePhone : "+44 12345656"
officeLocation : null
preferredLanguage :"en-GB"
surname : "Martian"
userPrincipalName : "[email protected]"
from office-js-helpers.
@azolson yes the username would be the UPN.
from office-js-helpers.
Related Issues (20)
- Google auth dialog showing "403 diallowed_useragent" HOT 1
- `plus.me` scope does not return email of user HOT 2
- OfficeHelpers.UI.notify has no background color in a React-based Office Add-in HOT 1
- office-js-helper with IdentityServer? HOT 1
- Double clicking the 'Allow' button on the dialog consent form in Word Online launches two dialogs HOT 1
- Office helpers gives undefined exception on Word 2016 HOT 3
- Storage.has(key) returns true even when the key actually doesn't exist.
- Missing any login dialog
- redirectUrl problem HOT 1
- Edge authentication popup doesn't close HOT 1
- IsAddin check fails in Browser, still returns true and uses Dialog framework HOT 3
- Authentication dialog not closing in Office Online on IE11(11.706.17134.0)
- Unable to delete 'AzureAD' from storage HOT 1
- redirect and automatically closing authentication dialog and token issue (MAC safari)
- Office Addin for Powerpoint : Dialog & authentication issue.
- Office Version 1907 / Windows 1903 - Authentication Redirect HOT 4
- feature request: Store token in OfficeRuntime.Storage HOT 1
- Authenticator: Make width and height of dialog window configurable
- State couldn't be verified
- displayDialogAsync does work in vanilla js but doesn't with react HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from office-js-helpers.