OneDrive / samples

Contains samples, scenarios, and guidance for integrating with OneDrive and SharePoint drives, drive items, and files.
MIT License
58 stars 59 forks source link

OneDrive example only works because of side-effect #34

Closed jonathon-love closed 1 year ago

jonathon-love commented 1 year ago

hi,

if you take a look here:

https://github.com/OneDrive/samples/blob/master/samples/file-picking/javascript-basic/scripts/auth.js#L17

you'll see that authParams is never defined, and so this attaches it to the window object.

in practice, this getToken() is called twice in quick succession, once with a command.type of 'SharePoint', and subsequentily with 'SharePoint_SelfIssued'. i have no idea what this SharePoint_SelfIssued thing is, but you have to respond to it the same way you'd respond to 'SharePoint'.

this is where the example gets tricky - because the switch() doesn't match 'SharePoint_SelfIssued', it falls to the default case and breaks ... with authParams having never been assigned to. however, it still works, because authParams is actually window.authParams and was assigned when getToken() was called with 'SharePoint' the first time.

but i don't think this is the intended behaviour ... it looks as though this only works like this by accident.

patrick-rodgers commented 1 year ago

Thanks, updated the sample.