RaynorUE / snich

Application for code work on a ServiceNow Instance
22 stars 4 forks source link

oAuth Setup does not seem to be working #213

Closed t1mb0b closed 2 years ago

t1mb0b commented 2 years ago

Describe the bug I have a number of instances configured, and have been using the plugin to edit and update code for some time now. Recently, the connections to instances stopped working, and I am seeing a popup stating:

SNICH record pull resulted in error running the contributed command 'snich.instance.pull_record' failed

So, I thought I would just re-configure the instance, as I have had issues in the past and when I did that, it started working again

However, once I get to the last step, with the oAuth callback, I am not getting anything on the URL which allows me to click the 'allow' button. I've tried on multiple browsers on multiple machines, and am getting the blank page and cannot click the 'allow' button to complete the setup

To Reproduce Steps to reproduce the behavior:

  1. Access the 'Setup new instance' command
  2. Populate the information for the 'oAuth' setup (client secret, client id, etc)
  3. Once browser window opens to complete the setup, there is no 'allow' button, just a blank page

Expected behavior At the last part of the setup, I should see an 'allow' button on the webpage which opens so I can contimue and complete the oAuth setup

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

RaynorUE commented 2 years ago

Thanks for all this detail!

Can you confirm if you're using SNICH or SNICH Canary?

I have had some lingering updates I need to merge into the core app from SNICH-Canary that improves a lot of these flows. but want to make sure i'm tracking down in the right version..

If you're not on SNICH Canary can you switch to that and give it a shot? Weirdly it's the most stable of the two items out there right now (I Just need to publish current Canary build to SNICH Prime... just a huge release notes list to build for that.. :( )

t1mb0b commented 2 years ago

Thanks Raynor! I am using Canary!

RaynorUE commented 2 years ago

Ahh, thanks for confirming. Oddly I think I was noticing that the other day as well! I'll get to the bottom of it this weekend. If not sooner!

On Thu, Oct 7, 2021 at 2:44 PM Tim @.***> wrote:

Thanks Raynor! I am using Canary!

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/RaynorUE/snich/issues/213#issuecomment-938101870, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACD6EWDZPYEEPLHTYOD4ELDUFX2CTANCNFSM5FRTSV4Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

RaynorUE commented 2 years ago

Hey there, just gave some OAuth setup a try, and it launched my browser and prompted the allow /deny OAuth prompt from the ServiceNow instance. Trying it on a Rome PDI and that part seemed fine.

Can you paste the URL it's trying to send you to in your browser? Remember to scrub your instance name out of the URL but the other parts pas the .service-now.com/ will be what I need. Additionally, a screencap of what you're seeing in your browser would be a huge help as well.

t1mb0b commented 2 years ago

image

Here is a screenshot of the browser window after entering the client id and secret; the page is blank. When I view source, there is no content. I have tried this on multiple browsers and operating systems with the same results. Even with a new install of the Canary version with no other instances configured.

I wonder if it's an issue on my local network? Or some other plugin blocking the page content? I cannot see any errors in the console. Again, I've tried this on multiple browsers (FFox, Opera, Edge), and Windows 10 and Linux OS with the same results.

Here is the full URL I am attempting to access:

https://dev53397.service-now.com/oauth_auth.do?response_type=code&client_id=&state=4a833a1118d5b8bca3a17b7de76094f0&redirect_url=https://localhost:62000

Let me know if you need anything else. Thanks for digging into this!

t1mb0b commented 2 years ago

One other thing I noticed, not sure if it's an issue- the Logo URL configured in the oAuth profile does not exist, it returns a 404:

https://github.com/RaynorUE/snich/blob/master/images/icon-sn-oauth.PNG%3Fraw=true

RaynorUE commented 2 years ago

Hrrm yea that is definitely odd... Uhm, I wouldn't THINK the image is affecting it, but it could? You could clear that value on the oAuth profile without issue and see if that's it.

If you're on your corporate network / VPN It could be doing something that wouldn't throw errors if it's intercepting the page or URL (I.e. detecting the text localhost in there and doing something weird). If you inspect the dom / open the console and look at the dom (Elements tab/section) is there anything there that makes it look like the page is rendering and being hidden? Or is it completely empty? If it's also completely empty, then yea something is gobbling up that HTML content as your computer is "downloading it".

The only other thing that's weird or at least makes me think it's nothing specifically coded in SNICH is that your still at the SN URL, which is all on SN for how that page renders / behaves. All I control is the "URL" you go to (when VSCode asks you to open your browser) and the query parameters on it. Which SN gives errors on the page if you get them wrong.

On Fri, Oct 8, 2021 at 10:40 AM Tim @.***> wrote:

One other thing I noticed, not sure if it's an issue- the Logo URL configured in the oAuth profile does not exist, it returns a 404:

https://github.com/RaynorUE/snich/blob/master/images/icon-sn-oauth.PNG%3Fraw=true

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/RaynorUE/snich/issues/213#issuecomment-938740212, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACD6EWDCTYRE7UEZASSGVH3UF4GGXANCNFSM5FRTSV4Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

t1mb0b commented 2 years ago

Thanks for your insights!

When I view source, there is no content on the page, it's just blank. Odd thing is, I am on my home network, and I don't have any policies or FW rules that might be blocking something. I do have a pihole for ad blocking, maybe that's causing issues? I will keep digging and let you know if I find anything!

t1mb0b commented 2 years ago

I just discovered if I delete the redirect_url parameter and then try to load the page again, it now displays the page with the allow button. Not sure why having the localhost in the redirect URL is an issue. I'll have to try this on a different network and confirm if it is in fact something on my home network.

RaynorUE commented 2 years ago

Ya i was thinking of mentioning that, but that would be really weird so I didn't... but it does allude to some sort of config on your computer (if it's a work computer?) But yea, the localhost is so it can send the Authorization Code back to VSCode / SNICH and it can use it to get an access/refresh token.

On Fri, Oct 8, 2021 at 2:03 PM Tim @.***> wrote:

I just discovered if I delete the redirect_url parameter and then try to load the page again, it now displays the page with the allow button. Not sure why having the localhost in the redirect URL is an issue. I'll have to try this on a different network and confirm if it is in fact something on my home network.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/RaynorUE/snich/issues/213#issuecomment-939054909, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACD6EWDN3XWIY42FAAYFAWDUF456PANCNFSM5FRTSV4Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

t1mb0b commented 2 years ago

Can you provide some insight on the original issue I was seeing:

SNICH record pull resulted in error running the contributed command 'snich.instance.pull_record' failed

The instance in question has been configured and I've used the plugin with it for some time. Now it seems all of my instances are showing the same error when I try to pull a record. That is why I was attempting to re-configure the oAuth.

RaynorUE commented 2 years ago

Right, if you're still able to reproduce the error. SNICH has quite a bit of logging into it.. You can turn it on in VSCode settings look for SNICH Log Level (Or just look through the SNICH Extension settings there are not very many) and you can set the log level to "Debug" which will give you copious amounts of detail to see what might have happened.

To view the logs, you'll need to open the "VSCode Developer Tools" which is under "Help" menu item along the top of VSCode. That should help us figure out where it might be throwing an error.

On Sat, Oct 9, 2021 at 10:41 PM Tim @.***> wrote:

Can you provide some insight on the original issue I was seeing:

SNICH record pull resulted in error running the contributed command 'snich.instance.pull_record' failed

The instance in question has been configured and I've used the plugin with it for some time. Now it seems all of my instances are showing the same error when I try to pull a record. That is why I was attempting to re-configure the oAuth.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/RaynorUE/snich/issues/213#issuecomment-939400293, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACD6EWARULBDQSG3INQ43PLUGEDNHANCNFSM5FRTSV4Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

t1mb0b commented 2 years ago

Thanks for all of your help with this! I've sorted out the issues, and I'll close this issue!

RaynorUE commented 2 years ago

Awesome, what did it end up being? Want to make sure I tie up any oddities / loose ends.

On Mon, Oct 11, 2021 at 4:12 PM Tim @.***> wrote:

Thanks for all of your help with this! I've sorted out the issues, and I'll close this issue!

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/RaynorUE/snich/issues/213#issuecomment-940443391, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACD6EWD4B3BNLHHIRABLEW3UGNHKZANCNFSM5FRTSV4Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

t1mb0b commented 2 years ago

The issue with the oAuth setup appears to be something on my local network; removing the redirect_url parameter allows for the setup to complete.

The other issue I was seeing with the pull error may have been due to an expired oAuth token. I saw some messages in the debug logs when I turned that on. I removed the 'snich.x' files in the .vscode folder and re-ran the authentication setup (removing the redirect_url parameter in the callback), and everything seems to be working fine.

So, it appears it was all issues on my end. Thanks for taking the time to assist with this! I learned a few things. I really like the plugin! Looking forward to upcoming enhancements!

RaynorUE commented 2 years ago

Ahh gotcha, yea I think there is a scenario (could be all scenarios) where I don't handle the refresh token properly. I.e. when it's expired re-launch the OAuth flow again... In the re-work (v2.0 is a total rewrite as I was learning NodeJS, Typescript, and VSCode extension authoring all at the same time when I wrote SNICH v1.0 ... ;) ) anyway in the re-work I am taking great care to make sure the OAuth components are test well as it A.) solvess the "I have SSO on my instances" and also solves "Me never having your local PW""... and lastly, I feel like the subsequent API calls are faster using the OAuth token..? could be placebo there...

On Tue, Oct 12, 2021 at 10:17 PM Tim @.***> wrote:

The issue with the oAuth setup appears to be something on my local network; removing the redirect_url parameter allows for the setup to complete.

The other issue I was seeing with the pull error may have been due to an expired oAuth token. I saw some messages in the debug logs when I turned that on. I removed the 'snich.x' files in the .vscode folder and re-ran the authentication setup (removing the redirect_url parameter in the callback), and everything seems to be working fine.

So, it appears it was all issues on my end. Thanks for taking the time to assist with this! I learned a few things. I really like the plugin! Looking forward to upcoming enhancements!

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/RaynorUE/snich/issues/213#issuecomment-941878211, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACD6EWEOVHF3UNJ43HMJXRDUGT227ANCNFSM5FRTSV4Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

t1mb0b commented 2 years ago

Sounds awesome, looking forward! I really wanted to use the official SN plugin, however I find it limiting in that it doesn't work in global scope (at least as far as I can tell form playing around). SNICH is just much easier to setup, and ever since the oAuth option was added, it's my go to now for developing, especially with large script includes and the like.

RaynorUE commented 2 years ago

Awesome and glad you're enjoying it! Yea, I'm not exactly sure what their thoughts were on locking it to a singular scoped application like they did. Plus the whole click in the status bar at the bottom to setup a project?? (They might have a command pallet option now...) I do feel that "laser focus" approach can be a bit annoying sometimes. I am definitely one for "provide the configurability / variability for your users to consume how they best see fit". While that means the UX can be a bit of a bear to get right, it always ends up best in the end IMHO. :)

Some other fun features coming down the pipe is the ability to specify a "Group by" field for a given application file type (, for example having UI Actions "Group by Table Name" would create sub-folders under UI Actions for each of the table names for the UI Actions synced. Same for business rules, etc.. Which will help keep those lists from being an absolute mess when you have a lot of those items going on.

Anyway, fun stuff :)

On Wed, Oct 13, 2021 at 10:53 AM Tim @.***> wrote:

Sounds awesome, looking forward! I really wanted to use the official SN plugin, however I find it limiting in that it doesn't work in global scope (at least as far as I can tell form playing around). SNICH is just much easier to setup, and ever since the oAuth option was added, it's my go to now for developing, especially with large script includes and the like.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/RaynorUE/snich/issues/213#issuecomment-942444552, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACD6EWCQP42T6NORLIAYK6DUGWTRDANCNFSM5FRTSV4Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

t1mb0b commented 2 years ago

Wicked!

Is there current functionality, or planned, to be able to send a query to pull multiple records? Say I want to pull all script includes created by me- is that possible?

RaynorUE commented 2 years ago

Ahhh, yea you're not the first person to ask. I have a colleague that's asked for something similar. I'll add it to the backlog so I don't forget... Just another "Command Pallete Path" ... "Load by app, Load by package" then "Sync record singular" and "Sync Records (by Encoded Query)" where it asks for the table first, and then provides some pre-defined queries? such as "Updated by me" OR "Created/Updated by Me" OR "Created by Me" or "Updated in last hour" or "Custom (paste encoded query)". I would then probably add another command palette option that would let you "Update Pre-Defined Sync Record Queries" where it will ask you to give it a name, define it it applies to a specific table, or "global / all app file tables" and then paste in the encoded query you want to use.. and then that would show up in the queries list.

Also, debating on giving an option to "Load all application files across all tables" based on those query parameters... I like the craziness of this idea, but concerned about the sheer amount of volume that could return and the processing time... It would probably hose an application node for a few minutes (since the API calls I make are multi-threaded). We'll see... maybe i'll add a "Use at your own risk" on it hahaha.

On Wed, Oct 13, 2021 at 11:08 AM Tim @.***> wrote:

Wicked!

Is there current functionality, or planned, to be able to send a query to pull multiple records? Say I want to pull all script includes created by me- is that possible?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/RaynorUE/snich/issues/213#issuecomment-942458825, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACD6EWF2OGCCL4MFWUAGFCLUGWVIJANCNFSM5FRTSV4Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.