Integrating Google Apis with Rails (Missing token endpoint URI Error) - ruby-on-rails-4

I want to use google apis in my app.
I successful get my access token but I am getting error :-
"Missing token endpoint URI."
My code is
def calender
client = Signet::OAuth2::Client.new(access_token: session[:access_token])
drive = Google::Apis::DriveV3::DriveService.new
drive.authorization = client
files = drive.list_files
end
when I printed my client variable, it showed my these details
#<Google::Apis::DriveV3::DriveService:0x0000010cc287f8
#root_url="https://www.googleapis.com/",
#base_path="drive/v3/",
#upload_path="upload/drive/v3/",
#batch_path="batch",
#client_options=#<struct Google::Apis::ClientOptions application_name="unknown", application_version="0.0.0", proxy_url=nil, use_net_http=false>,
#request_options=#<struct Google::Apis::RequestOptions
authorization=#<Signet::OAuth2::Client:0x0000010cc288c0
#authorization_uri=nil,
#token_credential_uri=nil,
#client_id=nil,
#client_secret=nil,
#code=nil,
#expires_at=nil,
#expires_in=nil,
#issued_at=nil,
#issuer=nil,
#password=nil,
#principal=nil,
#redirect_uri=nil,
#scope=nil,
#state=nil,
#username=nil,
#expiry=60,
#extension_parameters={},
#additional_parameters={},
#access_token="ya29.CjAbA8B7CFyhBLhFuEtP6kmCmuvJESwClkchiPpydjAqBOvDuvDERVCSVrYSSWLZvZc">, retries=0,
header=nil,
timeout_sec=nil,
open_timeout_sec=20>
I have spent two days to resolve this and explored whole internet but my issue is not resolved. My issue is related to already reported issue :-
Missing token endpoint URI while using a valid access_token
But solution provided in it is also not working for me. There is no attribute of "authentication" that I can use to assign my token.
I would greatly appreciate if someone help me with this.

Related

Unable to use any of the API of Zephyr Scale Server API (v1). Showing 404 Status / Dead Link issue

I am trying to use APIs from this https://support.smartbear.com/zephyr-scale-server/api-docs/v1/ documentation, where I am Unable to get the response. I am fulfilling all the specified requirements as mentioned in above documentation.
http://{My_Jira_URL}/jira/rest/atm/1.0/testcase/{Test_Case_ID}/attachments
The Auth type which I am using is Basic.
Here is a response which I am getting in postman
Can anyone let me know what I am doing wrong | what could be the cause behind this issue.
Or Else any alternate way or API resources to get Attachments for Jira-Zephyer Test cases?
You will need to use Zephyr scale API token as authorization to get a response for the APIs.
https://support.smartbear.com/zephyr-scale-cloud/api-docs/#section/Authentication

Postman cookies not set for subdomain (Postman Inceptor, Postman Native App)

i am playing around with Postman to get some insight on how things work behind the curtain and ran into, what I believe, is an issue but wanted to ask before I create a new issue on GitHub.
I am intercepting the request from my browser to the same site using the Postman Interceptor to use the request values in the native app. I have cookies enabled and the site (the whole domain) whitelisted.
When I use the history to resend the same request that was captured I get an auth error that is caused by the fact that the cookies are not included in the request (found that out by checking the cURL code snippet). I believe the reason for that is, that the cookies are set under another sub domain than that the request is send to.
I will try to include some pictures to clarify. My question here is:
Am I missing something/did I set something up in the wrong way
or is this an issue and I should create an issue in the official Postman Github page
cURL request
Cookies in Postman Native App
you should see if cookie is being send not using code snippet but the console :
its indeed sending cookies ,

Facebook API error : Message: (#324) Missing or invalid image file

I am getting an error while uploading an image to Facebook.
Both image and image path are proper but somehow it is not uploaded to Facebook when I am making a POST request to {pageid}/photos API call.
Here is my code.
$photoURL = 'https://www.example.com/images/img.png';
$uploadPhoto = $fb->post('/'.$pageId.'/photos', ['published' => 'false', 'url' => $photoURL]);
And it is giving following error.
Message: (#324) Missing or invalid image file
Please help me.
Thanks.
If you are trying to post from your localhost or virtualhost then error occurs because facebook can not find the url that you are providing.
Try this way:
search image from internet and pass its address to facebook SDK. I will post successfullty.
I was trying to send image from my virtualhost http:app.local.com/image-address and it gave same error. Then I picked an image form internet and passed then it was posted successfully.
Hope it solves your issue
For me it was the SSl certificate. It was on the server and valid over https, however I had an incorrect intermediate certificate on there. I saw the error when I checked the domain
https://cryptoreport.geotrust.com/checker/views/certCheck.jsp
Thanks
Grant

Bad request error with ruby google-api-client when querying Google Admin Directory API

I am using version 0.6.4 of google-api-client ruby gem to query Google Admin Directory API.
Here is my session in ruby console:
require 'rubygems'
require 'google/api_client'
SERVICE_ACCOUNT_CLIENT_ID = "SOME_STRING.apps.googleusercontent.com"
SERVICE_ACCOUNT_EMAIL = "SOME_STRING#developer.gserviceaccount.com"
SERVICE_ACCOUNT_PKCS12_FILE_PATH = "/path/to/privatekey.p12"
key = Google::APIClient::KeyUtils.load_from_pkcs12(SERVICE_ACCOUNT_PKCS12_FILE_PATH, 'notasecret')
asserter = Google::APIClient::JWTAsserter.new(SERVICE_ACCOUNT_EMAIL, "https://www.googleapis.com/auth/admin.directory.device.chromeos.readonly", key)
client = Google::APIClient.new
client.authorization = asserter.authorize
dir_api = client.discovered_api('admin', 'directory_v1')
resp = client.execute(:api_method => dir_api.chromeosdevices.list, :parameters => {'customerId'=>SERVICE_ACCOUNT_CLIENT_ID})
resp.body
=> "{\n \"error\": {\n \"errors\": [\n {\n \"domain\": \"global\",\n \"reason\": \"badRequest\",\n \"message\": \"Bad Request\"\n }\n ],\n \"code\": 400,\n \"message\": \"Bad Request\"\n }\n}\n"
I am probably missing something obvious here but it is unclear from the error response what is missing in the request. Would appreciate any help/pointers in the right direction.
Thanks.
I got a similar response in my C# program, listing users in my domain.
I still haven't resolved it but so far I managed to get the same error message in
The APIs Explorer https://developers.google.com/apis-explorer/#p/admin/directory_v1/
when trying to do the same request there and omitting any value for domain.
That led me to believe that I somehow needed to add the domain to my request in my C#-code and by trial and error I THINK I found how to do it in C#.
But my suggestion is to try your API request in the APIs Explorer and then se if you could get the same error message there by NOT submitting the value for domain, as I think that's what the error-message means.
I've had the same problems. I've wrote an example gist which explains how to set it up:
https://gist.github.com/thomaswitt/7468182
Steps are:
Go to Google Cloud Console (https://cloud.google.com/console)
Create Service Account with P12 File
Enable the Admin SDK in APIs.
Create a Project
Create a registered app within this project
Go to section 'Certificate' and generate a key
Download the JSON file as well
Go to the Apps Console > Security > Extended > 3rdPartgy OAuth
(https://admin.google.com/AdminHome?#OGX:ManageOauthClients)
Add an API Client. Client name is value of client_id in the JSON
file, API Scope is https://www.googleapis.com/auth/admin.directory.user.readonly
I found that #JoBe's answer was pretty much on track. In Ruby, using the Google-Api-Client gem, you need to pass a hash to list_users, with the domain. i.e.
UserService.list_users(domain: 'mydomain.com').

Facebook returning HTTP status code 502 while making a GET Request

I am trying a GET request from Facebook for a batch of ids using my app access token separated by a comma.
Please find below the call:
https://graph.facebook.com/?ids=1374186930,100005305471358,1516423103,100003031846875,100002939786624,100004705179654,522691095,100002893804783,100005269178084,1417831236,100004652521769,100003511989378,100002394692546,1646211152,1092931510,100000152985362,100004151552444,100004122698187,100001574061632,100005007584068&access_token=<my_app_access_token>&format=json
Facebook returns an error intermittently for some of these requests with an HTTP status code of 502.
I've tried fetching for these ids using the graph API explorer as well as the app access token later. They have been fetched properly. I have performed some research, but all issues of Facebook were related to open graph and 502 is "Bad Gateway Error". Since mine is not a web app, I cannot even refresh a browser to make the call again. This is a normal call made to Facebook API.
The error returned by Facebook is html which contains the following message:
"Sorry, something went wrong. We're working on getting this fixed as soon as we can."
Since they have given this response, I want to know if someone is facing this issue as well and if somebody could tell me, when this will be resolved.
This is affecting the other calls as well and there is a delay in the fetching.
Thanks in advance.
The Error 502 means that the message is too large. I do not know exactly the maximum size. Curiosity. What language are you using??
Good Bye