OneDrive/samples

OneDrive example only works because of side-effect

jonathon-love opened this issue · 1 comments

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.

Thanks, updated the sample.