as far as I can get gowalla auth code response contains both expires_at and expires_in but
expires_at is not valid date string so it throws error while comparing dates
any idea to hack omniauth or gowalla strategy would be very welcome!!!
rails 3.0.9
ruby 1.9.2
comparison of String with Bignum failed
oauth2 (0.5.0) lib/oauth2/access_token.rb:72:in `<'
oauth2 (0.5.0) lib/oauth2/access_token.rb:72:in `expired?'
oa-oauth (0.3.0) lib/omniauth/strategies/oauth2.rb:67:in `callback_phase'
{
"scope":"read",
"expires_at":"Sun, 09 Oct 2011 12:47:37 -0000",
"username":"altuure",
"expires_in":1172767,
"refresh_token":"XX",
"access_token":"XX"
}
Why don't you just use whatever you can. expires_in appears to be an interval, so you can do:
expires_at = Time.now + json["expires_in"].to_i
That said, the date string for expires_at definitely parses in 1.9.2-p290 (using DateTime.parse(str)). There's always DateTime.strptime if you need to parse a date/time string according to a given format.
sorry for delay but I commited the patch to the github you can find the details over here http://github.com/intridea/omniauth/issues/485 –
Related
ArgumentError in Users::OmniauthCallbacksController#google_oauth2
header field value cannot include CR/LF
Really unsure where this error is coming from.
I'm using ruby 2.5, Rails 5, and google-api-client 0.8.2
Any ideas how to fix or what information I can provide to make this question more informative?
Update: My logs show this when I am trying to authorize with Google's API
Google::APIClient::Request Sending API request get https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest {"User-Agent"=>"hello U/1.0.0 google-api-ruby-client/0.8.2 Mac OS X/10.13.4\n (gzip)", "Accept-Encoding"=>"gzip", "Content-Type"=>""}
And from my research, CRLF is "\r\n" characters, right?
So "User-Agent"=>"hello U/1.0.0 google-api-ruby-client/0.8.2 Mac OS X/10.13.4\n
is probably the issue.
So my question would be- how do I access User Agent in my request to fix this issue with Rails 5?
When using the Google::APIClient, the generated User-Agent may contains a CRLF. It can can be overridden in constructor. Example :
Google::APIClient.new(application_name: 'Foo', application_version: '1.0', user_agent: 'Foo/1.0 google-api-ruby-client/0.8.6 Linux/4.15.0-65-generic (gzip)')
You can modify the user_agent string to remove the CR/LF. I am using Rails 4.1.8 and google-api-client version `
#api_client = Google::APIClient.new(:application_name=>"Chronos", :application_version=>0)
# work around a bug that puts a CR/LF in the user agent string
#api_client.user_agent = #api_client.user_agent.gsub("\n", "")
Update gem google-api-client to version 0.20.0. It solves the problem but requires other changes to the application
Updating the version of the google-api-client gem did the trick for me.
When i include bcrypt to my mutation it is return failed to fetch error.
No mattter sync/async. When I generate hash only for logging , it showing the same error. Why it is acting like that?
bcrypt last version. Graphql-relay - 0.5.2
I'm unable to fetch response or send request to exotel sms api using the provided documentation on exotel rubygem http://www.rubydoc.info/gems/exotel/0.2
The documentations says to fetch response as follows:
sms = Exotel::Sms.details(sms_id)
But when I do that with an sms_id, ex. sms_id='12345678901234567890'
like
sms = Exotel::Sms.details("12345678901234567890")
it gives an error
TypeError: no implicit conversion of HTTParty::Response into String
I do have httparty gem installed. How to solve this?
The library is tested with 0.9.0 version of httparty that used to respond with Hash for http requests and the code is assuming it is string if not Hash and that is why it is failing
Here is the line causing the problem
exotel/response.rb
Quick fix would be to use 'httparty=0.9.0'
You may do it by using
gem "httparty","0.9.0"
Here is a working sample code, please update the account_sid and token with yours
gem "httparty","0.9.0"
require "exotel"
account_sid = "testexotel"
token = "9dcb4*******************e1dc2174fc47"
Exotel.configure do |c|
c.exotel_sid = account_sid
c.exotel_token = token
end
sms = Exotel::Sms.details("40a7*********258d411898b18b")
puts sms.status
puts sms.date_sent
Faraday Parsing Error 757
I'm new with Ruby and i'm trying to do a simple instragram integration using instagram gem.
I already configured tokens (access_token, client_secret, client_id) with Insagram.config()
Now i'm facing an error while trying to get recent media from instagram inside my controller.
The request:
#medias = Instagram.user_recent_media(196583629, {:count => 1})
The error:
Faraday::Error::ParsingError at /contests/385
757: unexpected token at '�'
Console:
faraday_middleware (0.9.1) lib/faraday_middleware/response/parse_json.rb:11:in `block in <class:ParseJson>'
I don't know if might be the response that i'm getting is broken etc..
Is there a way to check how and what's my response ?
Appreciate any help :)
Thanks.
I tried to replicate this, but the userid you gave is protected.
However, the following code works ok for me (using Snoop Doggs ID: 1574083)
require 'instagram'
Instagram.configure do |config|
config.client_id = ENV['INSTA_CLIENT']
config.client_secret = ENV['INSTA_SECRET']
end
#medias = Instagram.user_recent_media(1574083, {:count => 1})
puts #medias.first
However, unexpected token errors basically imply that the JSON given by the server is not valid json, normally because it's not JSON at all or it's invalid (leading " for example...)
If you do a manual curl of that userid, what do you get?
curl https://api.instagram.com/v1/users/196583629/media/recent/?client_id='clientidhere'
I'm using Ruby Rical to basically generate an icalendar as a response to an original icalendar specifing that I'm attending (accepting) the invitation.
I can generate the response correctly but I'm having a problem with timezones, basically if I let RiCal infer the correct Timezone, it works correctly depending on the TimeZone String specified in the original file.
Let me put this in examples:
I can reply this invitation from Google Calendar without problems:
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20091226T210000Z
DTEND:20091226T220000Z
DTSTAMP:20091223T191926Z
ORGANIZER;CN=xxx xxx:mailto:x...#xxxx.com
UID:4kkcos0ovgf9cvo3su6hlql...#google.com
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;RSVP=TRUE;CN=xxxx xxxx;X-NUM-GUESTS=0:mailto:x...#xxxx.com
CREATED:20091223T191925Z
DESCRIPTION:View your event at 4NmIxMmM1ZmJiODM4OTEx&ctz=America%2FLos_Angeles&hl=en.
LAST-MODIFIED:20091223T191925Z
LOCATION:800-292-2393 pin 1234
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:test google calendar attendance response
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR
But I'm getting an error (no such file to load -- tzinfo/definitions/US/Pacific) when I generate the response to an Ical (Mac Ical.app) invitation:
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
VERSION:2.0
METHOD:REQUEST
PRODID:-//Apple Inc.//iCal 4.0.1//EN
BEGIN:VTIMEZONE
TZID:US/Pacific
BEGIN:DAYLIGHT
TZOFFSETFROM:-0800
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
DTSTART:20070311T020000
TZNAME:PDT
TZOFFSETTO:-0700
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0700
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
DTSTART:20071104T020000
TZNAME:PST
TZOFFSETTO:-0800
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
ATTENDEE;CN="x...#xxxx.com";CUTYPE=INDIVIDUAL;PARTSTAT=NEEDS-ACTI
ON;RSVP=TRUE:mailto:x...#xxxx.com
DTEND;TZID=US/Pacific:20091231T091500
As you see TZID:US/Pacific is an invalid time zone indentifier for RiCal, so in these cases.. How would you do to answer this type of icalendar using Rical and conserving the original Timezone?
Please if I'm not clear with the question, ask me anything that you need.
I think RiCal uses TZInfo for its timezone support. You are presumably currently using the cut-down version of TZInfo that is included in Ruby on Rails' ActiveSupport library. This doesn't contain the US/Pacific timezone definition that you need.
The full version of TZInfo does include US/Pacific. If you install the tzinfo gem and then restart your Rails app, you should find that this works.