s-KaiNet / node-sp-auth

Unattended SharePoint http authentication with nodejs
MIT License
137 stars 56 forks source link

Undefined access token #102

Open mmorandini opened 2 years ago

mmorandini commented 2 years ago

When calling the getAuth() method in my integration (which has always worked until today), the headers object has Bearer undefined as value for the Authorization key.

As I said, the integration has always worked until today, which leaves me very confused.

mmorandini commented 2 years ago

Also worth noting that no errors are thrown whatsoever. Everything seems to be working fine, except the access token comes back as undefined.

koltyakov commented 2 years ago

Following an answer in Gitter:

mmorandini @mmorandini 14:37

Hello everyone, I have been experiencing a strange issue with the node-sp-auth package and I am hoping to get some help here hopefully. The issue is that when calling the getAuth() with client_id and client_secret only, everything seems to be working ok (in that I don't get any errors back), but when the promise resolves, the access token comes back as undefined, so the "headers" object looks like this: {'Authorization': 'Bearer undefined'}. Do you have any idea as to why this could be happening? Also worth mentioning that I have been observing this behavior only since yesterday, and that my integration was working fine before.

Andrew Koltyakov @koltyakov 14:53

Hi @mmorandini, did you prolongate the add in? By default an add-in registration is actual per a year, then needed secret update. https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/replace-an-expiring-client-secret-in-a-sharepoint-add-in

We may also add a fast fail check to the auth strategy for future, yet I have no outdated add-in to check at the moment.

mmorandini commented 2 years ago

Hi @koltyakov thanks for your help. I guess that would help should anyone have the same issue in future. Should I close the issue anyway?