carlowahlstedt / Spark_VSTS_Task

This is a library for creating a VSTS/TFS Task to post messages to Cisco Spark
MIT License
0 stars 1 forks source link

Access Token SyntaxError #1

Closed cyang2-nmdp closed 6 years ago

cyang2-nmdp commented 6 years ago

Hello - i'm trying to integrate your Cisco Spark addon into my VSTS build process and am running into this error: 2017-11-14T16:23:31.6873425Z ##[error]SyntaxError: Unexpected token { It appears this error is due to the Bot Access Token generated. Is there a specific format the token needs to be in? All I'm doing is copying the generated access token and pasting it into the Access Token field within the Spark tool. Could this error be something else besides the Access Token field? I've also attached a screenshot of my error.

syntax error

carlowahlstedt commented 6 years ago

I assume you followed the steps to create the token by creating a Bot? You should then get an access token for that Bot like this:

screen shot 2017-11-14 at 4 31 34 pm

If you've done these, you mentioned a VSTS build (as opposed to TFS). What build agent queue are you using?

cyang2-nmdp commented 6 years ago

Hi Carlo,

Yes I did. That’s how I got the one time access token. I used that access token to input into the “Access Token” field of the Spark tool. This is after I’ve created my team and space. Once the Team and Space has been created I’ve even added the bot into those team and space. Here’s a screenshot of my bot and the teams as an example. I’ve tried using the regenerated access token several times and got same error. This was the latest Bot.

[cid:image006.jpg@01D35D5F.3E58CE40]

[cid:image007.jpg@01D35D5F.3E58CE40]

[cid:image008.jpg@01D35D5F.3E58CE40]

From: Carlo Wahlstedt [mailto:notifications@github.com] Sent: Tuesday, November 14, 2017 3:36 PM To: carlowahlstedt/Spark_VSTS_Task Spark_VSTS_Task@noreply.github.com Cc: Chia Yang cyang2@NMDP.ORG; Author author@noreply.github.com Subject: Re: [carlowahlstedt/Spark_VSTS_Task] Access Token SyntaxError (#1)

I assume you followed the steps to create the token by creating a Bothttps://urldefense.proofpoint.com/v2/url?u=https-3A__developer.ciscospark.com_apps.html&d=DwMFaQ&c=C_O335FEx-vf3XHLXGN8TO1BAxpi8-UjLCbu_DQ0pZI&r=7wJ90zruB0usbYw7hFAbHw&m=a5YJzNy444q61KUYQTiq400aUnp54iHy1Q-anF7836o&s=HrHCUzsvEGVge2U7lBXGW43w8yfDZ2qZ3ZAgqZx_5Go&e=? You should then get an access token for that Bot like this: [screen shot 2017-11-14 at 4 31 34 pm]https://urldefense.proofpoint.com/v2/url?u=https-3A__user-2Dimages.githubusercontent.com_2687687_32806083-2D65a0b88a-2Dc959-2D11e7-2D8be9-2D44c78e0abe97.png&d=DwMFaQ&c=C_O335FEx-vf3XHLXGN8TO1BAxpi8-UjLCbu_DQ0pZI&r=7wJ90zruB0usbYw7hFAbHw&m=a5YJzNy444q61KUYQTiq400aUnp54iHy1Q-anF7836o&s=7fu53BRtcfGxTGISzleAawz9OAWm5y-nWC_X8A4OwGU&e=

If you've done these, you mentioned a VSTS build (as opposed to TFS). What build agent queue are you using?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_carlowahlstedt_Spark-5FVSTS-5FTask_issues_1-23issuecomment-2D344406798&d=DwMFaQ&c=C_O335FEx-vf3XHLXGN8TO1BAxpi8-UjLCbu_DQ0pZI&r=7wJ90zruB0usbYw7hFAbHw&m=a5YJzNy444q61KUYQTiq400aUnp54iHy1Q-anF7836o&s=E2g8q0KodUFjbkEoSusGFsxILwSYxdgIeOk0dK_bQro&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AgGvgzgxkScb7G-2DtJawBBWbfYzjOBbFpks5s2gfAgaJpZM4QdoPf&d=DwMFaQ&c=C_O335FEx-vf3XHLXGN8TO1BAxpi8-UjLCbu_DQ0pZI&r=7wJ90zruB0usbYw7hFAbHw&m=a5YJzNy444q61KUYQTiq400aUnp54iHy1Q-anF7836o&s=ssabz76PsfPZh6nnt23-Gw_gGHxG-R8zLtM1Vq-TN3E&e=.

carlowahlstedt commented 6 years ago

You mentioned a VSTS build (as opposed to TFS). What build agent queue are you using?

I guess it's also possible the message your passing to the bot is having issues. What is the message are you attempting to pass?

cyang2-nmdp commented 6 years ago

A simple text message "CIT Spark Build Message Test"

cyang2-nmdp commented 6 years ago

We use private build agents pool from VSTS. Is VSTS not supported?

carlowahlstedt commented 6 years ago

Only other thing that sticks out to me is that it doesn't seem to be able to talk to the API to begin with or otherwise it would output messages when looking for the room to begin with:

screen shot 2017-11-14 at 4 56 18 pm
carlowahlstedt commented 6 years ago

I haven't use the private build agent pool in VSTS, but I have used it in host VSTS build queue.

It's possible that your private build agent can't reach the spark servers for some reason?

cyang2-nmdp commented 6 years ago

It's possible. I can look into that. It's just the error message threw me off. Was thinking it was more related to the token. Will update after I check the build server. Thanks.

cyang2-nmdp commented 6 years ago

I did confirm and my build server can access the Spark team and space so I don't think that's an issue.

carlowahlstedt commented 6 years ago

I made some adjustments to the structure of the project to match some others. This was the first one I created and have learned several things since. While doing that, I noticed a compare issue when looking for a team. I've updated the task to fix that compare. I also noticed that I wasn't setting the success/fail result in all cases properly. Hopefully these will correct your issue.

cyang2-nmdp commented 6 years ago

Thanks for the update but seems the error is still reoccurring for me. I've tried to reinstall the tool, regenerated new BOT token with no luck. I'm guessing the difference may be hosted builds vs private builds. Maybe i'll wait to see if others run into same issue. Unless there are further updates.

cyang2-nmdp commented 6 years ago

Another question, do I need to submit my BOT to the Spark Depot for this to work? This is the only thing I have not done.

carlowahlstedt commented 6 years ago

I just checked and the bot I have that's working is not in the Spark Depot, so that doesn't seem to be a requirement.

Did you get the same output that you pasted before but with an updated version number? The version # should be different and I would have expected some different behavior too. I've seem the version get cached from the previously occasionally.

cyang2-nmdp commented 6 years ago

Yes I got the same output. I've tried uninstalling and reinstalling the latest version, regenerated new BOT token and still got same error. I've confirmed i'm using the latest version (0.2.7) from my build output. I'm having a different user test it out to see if it's something with my credential.

carlowahlstedt commented 6 years ago

Just pushed another update (0.2.9) which adds more logging, more often. Hopefully we can see some output before it just fails. That error just doesn't give much to go off of, but from what I understand that's the proper way to output the error.

Edit: had to fix an issue from previous change that didn't show up in my test build.

cyang2-nmdp commented 6 years ago

Great news. Looks like we got past the original error. We realize this is due to our private build agent not being up to date. Once we updated it to latest version we got past the original error. Now we are getting this error (2017-11-21T17:34:11.0990972Z Getting the rooms list 2017-11-21T17:34:11.2551002Z Looking for a match 2017-11-21T17:34:11.2551002Z ##[error]No Room Match Found for that Team)

Are Spaces and Rooms the same thing?

carlowahlstedt commented 6 years ago

I think so. Their api said rooms so that's the lingo I used but I realize the UI says spaces (and was only reminded when you asked just now). Glad to see we're finally getting somewhere.

cyang2-nmdp commented 6 years ago

Okay it's finally working for me. I believe the default 'General' space does not work. After I switched it to a new space I created it works. Everything is working now Carlo. Thank you very much for your help on this.