4

I previously had a Skype bot able to post messages using the API.

But on 11/17/17 I started getting this error on every attempt, and as a result, no message gets posted. I haven't changed anything.

requests.exceptions.HTTPError: 401 Client Error: The provided 'OAuth' ticket failed authentication. for url: https://apis.skype.com/v2/conversations/[conversation]/activities/

The process I use is to get an access token witha post to https://login.microsoftonline.com/common/oauth2/v2.0/token and then to use that token to post a message to https://apis.skype.com/v2/conversations/[conversation]/activities/

It's able to get the token fine, but then when the message post is called, it raises the above exception.

twasbrillig
  • 17,084
  • 9
  • 43
  • 67
  • Have you hard coded https://apis.skype.com/ into your bot? You should use the incoming messages serviceUrl to construct a reply. Skype messages will have a serviceUrl of https://smba.trafficmanager.net/apis/ – Eric Dahlvang Nov 20 '17 at 21:38
  • Thanks for your reply. I am hardcoding `"Host":"apis.skype.com"` into the header, and using the hardcoded URL as well. I'm not sure how to get the "incoming messages serviceUrl", how can I do that? All I am able to get right now is a token. – twasbrillig Nov 20 '17 at 22:09
  • the incoming message has a serviceUrl that should be used to reply: https://learn.microsoft.com/en-us/bot-framework/rest-api/bot-framework-rest-connector-send-and-receive-messages#send-the-reply – Eric Dahlvang Nov 20 '17 at 22:21
  • Hmm. The bot isn't set up to receive messages from users; it only posts messages itself. – twasbrillig Nov 20 '17 at 23:21
  • Have you tried https://smba.trafficmanager.net/apis as the base url, and /v3/conversations/{conversationid}/activities/{activityid} ? Your code posted above is using https://apis.skype.com as the base url and /v2/conversations/{conversationid}/activities – Eric Dahlvang Nov 20 '17 at 23:36
  • I get `HTTPError: 401 Client Error: Unauthorized for url: https://smba.trafficmanager.net/apis/v3/conversations/[conversationid]/activities/` ...but perhaps that's because I don't have an activityid to pass in? – twasbrillig Nov 21 '17 at 00:20
  • 1
    My skype bot used only SEND messages and keep returning 401 last few days. Changing send url to https://smba.trafficmanager.net/apis/v3/conversations /{}/activities didn't get any result I get auth token successful but it's still doesnt work `('{"message":"Authorization has been denied for this request."}', 401)` – E.Big Nov 21 '17 at 17:45
  • May be is there any other new auth endpoint? Because in Docs so many new things about API v3 but Auth section still point to login.microsoftonline.com/botframework.com/oauth2/v2.0/token – E.Big Nov 21 '17 at 17:49
  • @twasbrillig activityId only needs to send **reply** . In our case when bot works just as notification manager we keep using v3/conversations /{}/activities , with new baseurl I guess only. But it's still doesnt work – E.Big Nov 21 '17 at 17:52

1 Answers1

8

I've faced with exactly the same problem and this worked for me:

I left all send messages endpoint as is for v2, BUT in token generation POST payload I've changed 'scope' -> 'https://api.botframework.com/.default'

E.Big
  • 723
  • 6
  • 15