I am trying to use the Twitter API v2, but every time I do run on the site, I get an error:
Atymic\Twitter\Exception\Request\UnauthorizedRequestException
A request error occurred. Client error: GET https://api.twitter.com/2/tweets/search/recent?place.fields=country%2Cname&tweet.fields=author_id%2Cgeo&expansions=author_id%2Cin_reply_to_user_id&query=a resulted in a 401 Unauthorized response: { "title": "Unauthorized", "type": "about:blank", "status": 401, "detail": "Unauthorized" }
Here is the responsible controller.
Mediacontroller:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Atymic\Twitter\Twitter as TwitterContract;
use Illuminate\Http\JsonResponse;
use Twitter;
class mediacontroller extends Controller
{
public function searchRecent(string $query): JsonResponse
{
$params = [
'place.fields' => 'country,name',
'tweet.fields' => 'author_id,geo',
'expansions' => 'author_id,in_reply_to_user_id',
TwitterContract::KEY_RESPONSE_FORMAT => TwitterContract::RESPONSE_FORMAT_JSON,
];
return JsonResponse::fromJsonString(Twitter::searchRecent($query, $params));
}
}
And here is the Routing
Route::get('media/{query}',[mediacontroller::class,'searchRecent']);
And when run, the out come is, you can head over and test it yourself its https://mytry.studio/media/. what follows after the media/ is the query.
The reference of all the code is from the atymic documentation on github
atymic github documentation
Related
I am trying to have a game to request data from the Google Sheets API, and I can't get the API Key to function properly. I can visit my API Link in the browser, and it tells me it is getting HTTP 400 (Bad Request) and Google additionally says it's a bad API Key, despite having JUST generated it. For reference my link looks like this: "https://sheets.googleapis.com/v4/spreadsheets/[SHEET_ID]?key=[API_KEY]/values", and the browser views this when using it:
"error": {
"code": 400,
"message": "API key not valid. Please pass a valid API key.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "API_KEY_INVALID",
"domain": "googleapis.com",
"metadata": {
"service": "sheets.googleapis.com"
}
}
]
}
}
I have absolutely no idea what is going wrong, I know the API key and Sheet ID are right (Directly copied each from their respective source).
I created a simple Rest Endpoint in java using jersey as you see in the following:
#Path("/study")
public class CreateRestEndpoint {
private static String endpoint;
#PUT
#Consumes("application/fhir+json")
#Produces(MediaType.APPLICATION_JSON)
public Response getPut(IBaseResource list){
System.out.println("UpdatedResource.: "+list);
return Response.status(200).build();
}
#PUT
public Response getTest(String str) {
System.out.printf(str);
return Response.status(200).build();
}
When I use postman and I send a PUT request to jersey-servlet, everything is ok and the jersey-servlet gets the message immediately.
But I created jersey-servlet to get a message which is sent by FHIR server (my FHIR server is running in docker) via Subscription resource. Actually, I'm trying to use subscription mechanism to be notified when a List resource is updated.:
{
"resourceType": "Subscription",
"id": "9",
"meta": {
"versionId": "2",
"lastUpdated": "2019-11-08T09:05:33.366+00:00",
"tag": [
{
"system": "http://hapifhir.io/fhir/StructureDefinition/subscription-matching-strategy",
"code": "IN_MEMORY",
"display": "In-memory"
}
]
},
"status": "active",
"reason": "Monitor Screening List",
"criteria": "List?code=http://miracum.org/fhir/CodeSystem/screening-list|screening-recommendations",
"channel": {
"type": "rest-hook",
"endpoint": "http://localhost:8080/notification/study",
"payload": "application/fhir+json"
}
}
When I change the List resources in FHIR, I expected to arrive a message in the jersey-servlet but unfortunately I get the following error (when I set the endpoint to a test rest-hook like webhook.site samples, I can get the message from FHIR side):
fhir_1 | 2019-11-08 18:48:40.688 [subscription-delivery-rest-hook-9-13] INFO c.u.f.j.s.m.i.S.SUBS6 [SubscriptionDebugLogInterceptor.java:162] Delivery of resource List/4/_history/17 for subscription Subscription/9 to channel of type RESTHOOK - Failure: ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException: HTTP 404 Not Found
fhir_1 | Exception in thread "subscription-delivery-rest-hook-9-13" org.springframework.messaging.MessagingException: Failure handling subscription payload for subscription: Subscription/9; nested exception is ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException: HTTP 404 Not Found, failedMessage=ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryJsonMessage#330c0fdb[myPayload=ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage#38a1c8a2[mySubscription=ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription#1d55d025[myIdElement=Subscription/9,myStatus=ACTIVE,myCriteriaString=List?..........
..................................................
What is the problem? I tried a lot with different parameters but no solution found.
I changed #Path to #Path("/study/List/{var}"), but I got the same failure again. Actually my FHIR server is running in docker and probability the problem would be inside the Docker.
After setting the Proxy in Docker, everything fine...
Conclusion: I had to change the #path to #Path("/study/List/{var}")and set the Proxy in Docker.
I'm trying to connect to google home using OAuth2.0 mechanism. However, hitting with an issue where I'm not able to retrieve success message.
The failing request is - https://oauthintegrations.googleapis.com/v1/token:getForService
with the response payload as redirectState. I know about redirect but what is redirectState? I tried to search a bit over this one, but failed.
Any help would be appreciated.
Note:I have followed all the necessary steps mentioned in doc, I can receive authorisation code, but not able to make token request to desired endpoint.
The docs are https://developers.google.com/actions/identity/oauth2-code-flow and https://developers.google.com/actions/identity/account-linking.
In configuration settings we have Linking type as Oauth -> Authorization Code.
In dialog flow in Integration -> Integration Settings we have checked in for 'Sign in required' for Default Welcome Intent and have the firebase function as
app.intent('Default Welcome Intent', (conv) => {
conv.ask(new SignIn());
});
according to https://developers.google.com/actions/identity/account-linking document and I am currently using API version V2.
After the auth code is received as mentioned it does not call token url, we receive this screen :
Bad response from IdP in Auth Code Exchange & what is redirect_state
The https://gala-demo.appspot.com/app#redirect_state=XXX&state=yyy&service=abc when inspected fails at https://oauthintegrations.googleapis.com/v1/token:getForService as mentioned by #rajesh with status code 400, but when this request is made through postman it return the response. Here is the body and response for the request.
Body :
{
"credential" : {
"redirectState": "XXX"
},
"scopes": [],
"gdiState": "APP_AUTH",
"serviceId": "tapclicks-integration-adac2_dev"
}
RESPONSE :
{
"serviceInfo": {
"authUrl": "https://-domain-/authorization",
"name": "tapclicks dashboard",
"logoUrl": "https://placeholder.com/",
"clientId": "zdqexVMaVvxIMQ7Frjwa",
"tokenUrl": "https://-domian-/token_url",
"privacyPolicyUrl": "https://placeholder.com/",
"tosUrl": "https://placeholder.com/",
"id": "tapclicks-integration-adac2_dev"
},
"completionInfo": {
"appauthInfo": {
"appauthRedirectUrl": "https://-domain-/authorization?response_type=code&client_id=zdqexVMaVvxIMQ7Frjwa&redirect_uri=https://oauth-redirect.googleusercontent.com/r/tapclicks-integration-adac2&scope=gmail&state=yyy",
"appauthRedirectState": "abcxxx"
},
"oauthAuthorizationUrl": "https://-domain-/authorization?response_type=code&client_id=zdqexVMaVvxIMQ7Frjwa&redirect_uri=https://oauth-redirect.googleusercontent.com/r/tapclicks-integration-adac2&scope=gmail&state=yyy"
},
"gdiState": "APP_AUTH",
"header": {}
}
Can you please tell if i might be making any configuration mistake or any other info you need.
Authorization Url : https://kprb95tye7.execute-api.us-east-1.amazonaws.com/authorization/
Token Url : https://9343j46f16.execute-api.us-east-1.amazonaws.com/token_url/
Thanks
I'm using the Microsoft Graph People API and when I look at the docs here you can get a person by using its id:
I use the Graph Explorer to get people with the following API call:
https://graph.microsoft.com/v1.0/me/people?$select=id
I successfully get a list of ids.
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users...",
"#odata.nextLink": "https://graph.microsoft.com/v1.0/me/people?$select=id&$skip=10",
"value": [
{
"id": "ddb9e9e4-a4cc-46ee-93f4-ba135920c84a"
},
{
"id": "37136f8b-33b3-4596-a63b-d41dc8edda34"
},
{
"id": "8c13d891-bd2f-42e5-8650-450b3318f8e3"
}
]
}
Then I use one of the ids to get more info about a single person by using this call:
https://graph.microsoft.com/v1.0/me/people/ddb9e9e4-a4cc-46ee-93f4-ba135920c84a
And I get an error:
{
"error": {
"code": "ErrorInternalServerError",
"message": "An internal server error occurred. The operation failed.",
"innerError": {
"request-id": "6e138441-5e1d-4f04-a87b-8141547cbb07",
"date": "2018-05-04T06:36:22"
}
}
}
Am I doing sth wrong ?
I'm also getting this error when following Microsoft's documenation.
As a workaround I added a filter.
https://graph.microsoft.com/v1.0/me/people?$filter=id eq 'ddb9e9e4-a4cc-46ee-93f4-ba135920c84a'
Unfortunately is seems that filtering by id is not supported at this time.
If you have the persons name you can use a filter like this:
https://graph.microsoft.com/v1.0/me/people?$filter=givenName eq 'Baris'
At the end of the day I prefer to use /users endpoint to get this type of information.
https://graph.microsoft.com/v1.0/users?$filter=id eq 'ddb9e9e4-a4cc-46ee-93f4-ba135920c84a'
or
https://graph.microsoft.com/v1.0/users?$filter=startswith(givenName, 'Baris')
Hope this helps!
I'm passing the following to the youtube.channels.list method in the YouTube Data API (v3).
[key] => foo,
[forUsername] => royaloperahouse,
[part] => topicDetails
But my response just contains a 500 Internal Server Error:
{
"error": {
"code": 500,
"message": null
}
}
I get the same behaviour from the Google Developers Console. What could be causing this? Am I missing something here?
YouTube confirmed this was an API bug and it was subsequently fixed.