My chatbot needs to start a new converstaion/reply chain in a public Microsoft Teams channel. Unfortunately, I'm getting a 403 BotNotInConversationRoster error when sending a POST request to /v3/conversations.
My requests POST /v3/conversations (see API reference) looks as follows (note: I removed the access token):
curl -X POST -H "Authorization: Bearer XXX" -H "Content-Type: application/json" https://smba.trafficmanager.net/de/v3/conversations -d '{"activity":{"text":"Test","type":"message"},"channelData":{"channel": {"id": "19:62fb45ddd8b2447082e5d1694ce8d735#thread.skype"}}}'
I don't understand the resulting error message.
{"error":{"code":"BotNotInConversationRoster","message":"The bot is not part of the conversation roster."}
From my understand an installed chatbot with scope team should be a member of each public channel by default. Or am I missing something?
Any ideas/examples?
It sounds like it could be that the Bot registration in Azure doesn't have the Teams channel configured properly - see the image for reference
To send bot notifications to the channels in ms teams, you should have install the bot app for team(not only for chat).
You can install your bot app to team either by
Add app to team manually in ms teams dashboard.
By using graph api, https://learn.microsoft.com/en-us/graph/api/teamsappinstallation-add?view=graph-rest-1.0&tabs=http
Related
TL;DR: It seems to me that the problem is in the "redirect_state" query parameter in the redirect_uri. Instagram fails oauth2 requests with any query params.
I tried both drf-social-oauth2 and django-rest-framework-social-oauth2 python packages, with the same result.
I receive a 400-response from Instagram API:
400 Client Error: Bad Request for url: https://api.instagram.com/oauth/access_token
Reproducing the process from the console I get more details. A body of the response is:
{"error_type": "OAuthException", "code": 400, "error_message": "Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request"}
Steps to reproduce the behaviour:
Set "Valid OAuth Redirect URIs" in an "Instagram Basic Display" app.
https://api.mydomain.com/auth/complete/instagram/
https://api.mydomain.com/auth/complete/instagram
Redirect my client to the URL:
https://api.instagram.com/oauth/authorize
?client_id=<my_client_id>
&redirect_uri=https://api.mydomain.com/auth/complete/instagram/?redirect_state=<value>
&scope=user_profile,user_media
&response_type=code
When the client is redirected, copy code from the URL.
Then I reproduce the libraries' request:
curl -X POST \
https://api.instagram.com/oauth/access_token \
-F client_id=<my_client_id> \
-F client_secret=<my_app_secret> \
-F grant_type=authorization_code \
-F redirect_uri="https://api.mydomain.com/auth/complete/instagram/?redirect_state=<value>" \
-F code=<code_copied_from_clients_url>
Receive 400-response:
{"error_type": "OAuthException", "code": 400, "error_message": "Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request"}
In my Instagram profile (https://www.instagram.com/accounts/manage_access/) I see successfully added my Instagram business app.
Expected behaviour
At step 5 I expect to receive an access_token and a user_id:
{"access_token": "<access_token>", "user_id": <user_id>}
And it works this way, only in case I remove test=test from the both: auth URL from the 2nd step and the 4th step.
Additional context
I use python 3.9.7 with:
Django==3.2.10
social-auth-app-django==5.0.0
social-auth-core==4.1.0
django-oauth-toolkit==1.6.1
My Facebook/Instagram app didn't published ("App Mode: Development"). But my Instagram accounts (which I use for testing) is added as a Tester into the Facebook/Instagram app.
I even tried to put test instead of redirect_state query parameter, and it doesn't work too.
My app settings:
I'm not sure that the problem is in the library. Maybe in my Instagram business app configuration. But I don't have any clue to get how to fix it.
Ref - https://support.oracle.com/cloud/faces/DocumentDisplay?id=2637471.1&_adf.ctrl-state=h87zqwsi3_730&_afrLoop=213040896345615
Can anybody help with a sample payload to invoke 'Import Applications' POST method to programmatically import the application to the Oracle Visual Builder Cloud Service.
I know I don't have the Content-Type or the request body or both not correct. I'm using Postman to test the endpoint
Steps
Setup the Oracle Visual Builder Cloud Service instance in https://cloud.oracle.com/?region=
Created an 'Visual Builder' instance in oracle cloud for my login/ tenancy
Launched the VBCS home page and created one or more applications
Used the VBCS REST endpoint (GET /resources/application/exportresources/{projectid}-{version}) to export one of the applications
I'm trying to import the application (POST /resources/application/importresources) to another VBCS instance but unable to determine the correct 'Content-Type' or the request payload format. I keep getting HTTP 415 or 400 error
Code shown below. SERVICENAME-CLOUDACCOUNT.SERVICETYPE is replaced from oracle cloud account.
curl --location --request POST 'https://SERVICENAME-CLOUDACCOUNT.SERVICETYPE.ocp.oraclecloud.com/ic/builder/resources/application/importresources' \
--header 'Authorization: Bearer yourOAuthToken' \
--header 'Content-Type: application/vnd.oracle.adf.error+json;application/json;application/vnd.oracle.adf.resourceitem+json;application/vnd.oracle.adf.resourcecollection+json' \
--header 'REST-Framework-Version: 4' \
--data-raw '{
"branchId": "0",
"importMode": "xyz",
"name": "Test",
"description": "sample",
"location": null,
"fileName": "abc",
"unzip": null
}'
Instead of hacking your way around - how about using the proper way of storing your code in a Git repo and then using the CI/CD features of VB Studio to move your app from one instance to the other?
This will also make upgrades of the app simpler going forward.
Here is an intro:
https://blogs.oracle.com/vbcs/post/automate-visual-applications-cicd-with-visual-builder-studio
I debugged the visual builder cloud instance logs to find the details of the rest api call. When importing the application from the front end ( OVBCS development platform UI ), the logic utilizes the 'Import Applications' endpoint.
Here is the working curl script for importing application resources to the oracle visual builder cloud instance using the REST end points
Login to Oracle Cloud using your cloud account credentials and tenancy
On navigation menu on top left -> OCI Classic Services -> Platform Services -> Visual Builder
Create an instance if you don't have one already. Click on the active instance and Start it up
Grab your VBCS instance base url. It will be something like https://yourInstanceName-yourTenancy.builder.ocp.oraclecloud.com/ic/builder/
Assuming you have a visual application created in your VBCS instance. Ref here
Assuming you are familiar with generating bearer token for oracle cloud applications. The OAuthToken mentioned in the below samples are generated based on your preferred OAuthType ( ResourceOwner or JWT or whatever setup you have for your cloud application)
Export your application. response will be zip file contents. save it to your file system
curl --location --request GET 'https://yourInstanceName-yourTenancy.builder.ocp.oraclecloud.com/ic/builder/resources/application/exportresources/yourAppId-yourAppVersion' --header 'Authorization: Bearer OAuthToken'
Let's say you saved the exported file in C:\temp\yourAppId-yourAppVersion.zip
Import your application as new application in the target instance
curl --location --request POST 'https://yourInstanceName-yourTenancy.builder.ocp.oraclecloud.com/ic/builder/resources/application/importresources?branchId=yourAppId&importMode=CREATE_NEW_APP&name=yourAppName&description=SomeOptionalDesc&fileName=yourAppId-yourAppVersion.zip&unzip=true' --header 'Authorization: Bearer OAuthToken' --header 'Content-Type: application/zip' --data-binary '#/C:/temp/yourAppId-yourAppVersion.zip'
Import your application to an existing application in the target instance. It will override the existing application version with the contents that you are importing.
curl --location --request POST 'https://yourInstanceName-yourTenancy.builder.ocp.oraclecloud.com/ic/builder/resources/application/importresources?branchId=yourAppId-yourAppVersion&importMode=KEEP_EXISTING&name=YourAppName&description=SomeOptionalDesc&fileName=yourAppId-yourAppVersion.zip&unzip=true' --header 'Authorization: Bearer OAuthToken' --header 'Content-Type: application/zip' --data-binary '#/C:/temp/yourAppId-yourAppVersion.zip'
I have an internal API that I'm making available through Azure App Proxy with AAD Pre-authentication.
Now I want to call that API from a MessageCard HTTPPost action in Teams.
When I click on the action button I do not see any errors, and Fiddler shows me a 200 respose and I can see the token in the authorization header and the below in the body:
{"status":"Completed","actionId":"65d36e8b-e90a-4007-a556-bc4c74da8f1e","performedAt":"2019-12-03T16:23:45.0463267Z","properties":{"displayMessage":""}}
But nothing happens after that.
Am i missing something?
Can you test your API with Webhook.site and see if you are able to get proper response.
Trying to build an Angular 6 application to display all photos from a particular Google Photos album. Before implementing the Angular portion, I wanted to see if I could get the data from a cURL command, using the API key I created and gave access to the Photos API.
cURL:
curl -X GET \
'https://photoslibrary.googleapis.com/v1/mediaItems?pageSize=1&key=[API KEY]' \
-H 'Accept: application/json' \
This is based on the samples from Google's documentation here: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/list
However, adding my valid API key results in the following error:
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
Is there additional data required besides the API key to get this working? Is it even possible to use an API key in this manner, or does it require using OAuth 2.0 and all the additional hoops that come with it?
You need to obtain an OAuth AccessToken to add as an HTTP Header in your request.
Here's a breakdown of the process I've used that has worked, with the caveat that it periodically gets 401 errors from the mediaItems requests. It seems that Google is throttling the requests and denies a few if they're coming too fast.
We are using our own logging solution because stackdriver is su...bpar. I want to pull the metrics on how many unacknowledged messages there are in the pubsub. Started to read the docs on that and they are all over the place.
Found this page:
https://cloud.google.com/monitoring/api/metrics
Despite being under the api it does not describe any api calls, but does contain the description of the metric I want to extract.
Now I am thinking I need to use the monitoring api to extract what I need somehow:
https://cloud.google.com/monitoring/api/ref_v3/rest/
So I use the api explorer to try a couple of methods:
https://developers.google.com/apis-explorer/#search/monitoring/monitoring/v3/monitoring.projects.groups.list
I query and gives me an available url:
GET https://monitoring.googleapis.com/v3/projects/myprojectname/groups?key={YOUR_API_KEY}
I go to my project's console (api & credentials page) and generate an api key without restrictions and paste it in trying to curl.
curl https://monitoring.googleapis.com/v3/projects/myproject/groups?key=myrandomkeylkjlkj
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
Why is this happening? How can I get the metrics? I went to the url provided but it explains oauth token creation and has nothing regarding the api keys. I just need to curl things to make sure I am going the right way.
Why does this have to be so hard? Killed several hours of my life trying to get this.
curl -H "Authorization: Bearer $(gcloud config config-helper --format='value(credential.access_token)')" https://monitoring.googleapis.com/v3/projects/myproject/groups