Code Monkey home page Code Monkey logo

Comments (27)

mschwartz avatar mschwartz commented on August 21, 2024

If I make no calls to snoowrap, I don't see an error thrown.

If I call r.get_hot(), I get this:

image

from snoowrap.

not-an-aardvark avatar not-an-aardvark commented on August 21, 2024

Thanks for the report -- I'll look into seeing if I can get the browser build to work with Safari.

However, could you clarify what you mean when you say that snoowrap is catching a google maps API error?

from snoowrap.

abdulhannanali avatar abdulhannanali commented on August 21, 2024

I think he means that you shouldn't be looking into that error because ExtJS framework might be the cause of it

from snoowrap.

mschwartz avatar mschwartz commented on August 21, 2024

ExtJS is not the cause of it. Loading font awesome or google maps api from
Google servers causes the problem.

Aside from making robots, you'd think this is ideal for making mobile or
browser apps.
On Tue, Jun 28, 2016 at 3:25 PM Hannan Ali [email protected] wrote:

I think he means that you shouldn't be looking into that error because
ExtJS framework might be the cause of it


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#32 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAUHpU0wxaBfpFdikI3IUNpHjp5fiDi9ks5qQZ9jgaJpZM4JAkCM
.

from snoowrap.

not-an-aardvark avatar not-an-aardvark commented on August 21, 2024

This was closed because I fixed the Safari issue, but I guess I'll reopen it for the google maps issue.

Would you mind providing sample code for how you're interacting with google maps/snoowrap? I can't think of how snoowrap would be interfering with your requests to the google maps API.

from snoowrap.

mschwartz avatar mschwartz commented on August 21, 2024

It is ExtJS that is causing Google maps API to be yanked in, locally (e.g.
Not from a cdn). It's probably adding a script tag dynamically.

The issue is that the Maps API is fetching additional js files from cdn.

I've initiated a get_hot request and before it finishes, the Maps API
returns a "not logged in" status. It appears to me snoowrap is trying to
parse that response.
On Tue, Jun 28, 2016 at 5:36 PM not-an-aardvark [email protected]
wrote:

Reopened #32 #32.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#32 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAUHpTT-yHaN4KIayeNcDDksIqrnGLcpks5qQb4DgaJpZM4JAkCM
.

from snoowrap.

not-an-aardvark avatar not-an-aardvark commented on August 21, 2024

I see -- what makes you think that snoowrap is trying to parse that response?

(Sorry for asking so many questions, but I'm still not sure I understand what's going on.)

from snoowrap.

mschwartz avatar mschwartz commented on August 21, 2024

Can you see the error snoowrap threw? I included it in one of my previous comments here. That' kind of output is not anything I've seen in any other JavaScript environment.

https://cloud.githubusercontent.com/assets/329637/16433270/380d7b68-3d3e-11e6-962a-4d773fe2a36d.png

Also, the issue only occurs when running the app in emulation mode in the developer tools. The app runs fine as a desktop app. The only difference is font awesome and google maps.

If I comment out snoowrap, the app works in emulation mode.

When I look at the network tab, I see the request to reddit succeeds, then after a few seconds the other requests for google assets succeed but the login auth to google apis fails and the error I see is thrown. The .then() for the reddit request doesn't seem to be called.

What else can I tell you?

from snoowrap.

not-an-aardvark avatar not-an-aardvark commented on August 21, 2024

When I look at the network tab, I see the request to reddit succeeds

What's the endpoint of the request to reddit that succeeds? snoowrap has to make several requests to reddit at first (to get an access token before it can start accessing the API directly).

From that screenshot, it seems like the request to https://oauth.reddit.com/hot?raw_json=1&count=9999 is failing, and that's causing the error that gets thrown. I think the issue with the google API login might be unrelated to snoowrap.

from snoowrap.

mschwartz avatar mschwartz commented on August 21, 2024

I think I see what's going on.

When using the desktop framework, snoowrap is generating an http request to reddit. When running in the mobile framework, snoowrap is generating an https request that is getting a 302 response.

Maybe have a look at what circumstances you are generating https requests?

The URL in my browser is not https.

from snoowrap.

mschwartz avatar mschwartz commented on August 21, 2024

image

from snoowrap.

not-an-aardvark avatar not-an-aardvark commented on August 21, 2024

Hmm, it seems like reddit is redirecting the OAuth request to its mobile HTML site (http://m.reddit.com) since it identifies that you're on a mobile device based on the user-agent. That could be a bug with the reddit API.

Have you tried using a different user-agent with snoowrap?

from snoowrap.

mschwartz avatar mschwartz commented on August 21, 2024

No, but I could try.

I'm using navigator.userAgent :)

from snoowrap.

mschwartz avatar mschwartz commented on August 21, 2024

I am a bit confused by this, though:

image

The request URL is https.

from snoowrap.

mschwartz avatar mschwartz commented on August 21, 2024

Using hardcoded user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"

Still fails.

from snoowrap.

not-an-aardvark avatar not-an-aardvark commented on August 21, 2024

I'm using navigator.userAgent :)

I think that might be what's causing the issue. Reddit has some guidelines here on choosing a good user-agent string; basically, it sometimes does things unexpectedly if it thinks the request is coming from a browser trying to access the normal site.

Try making your user-agent something different, related to your app.

from snoowrap.

not-an-aardvark avatar not-an-aardvark commented on August 21, 2024

I am a bit confused by this, though:

image

The request URL is https.

That's as intended; in fact, all OAuth requests are required to use https. I'm not sure why reddit redirects to the http: version of its mobile site, though.

from snoowrap.

mschwartz avatar mschwartz commented on August 21, 2024

I don't know how reddit's server is able to detect mobile browser given that I'm passing giving it a user_agent that is the desktop browser's string.

Some more info:

image

and

image

and

image

those requests are not being redirected...

from snoowrap.

mschwartz avatar mschwartz commented on August 21, 2024

Aha

image

from snoowrap.

not-an-aardvark avatar not-an-aardvark commented on August 21, 2024

I went ahead and removed the image from your last comment as a precaution, since it contained your client credentials (in the "Authentication" header, encoded in base64). You may want to edit that out of the image.

from snoowrap.

mschwartz avatar mschwartz commented on August 21, 2024

Appreciate it. I fixed the image.

Anyhow, maybe you can override the user-agent header with user_agent configuration/option?

from snoowrap.

not-an-aardvark avatar not-an-aardvark commented on August 21, 2024

In theory snoowrap already does that, and it seems to set the header correctly in node, at least. I'm not sure why it's not working in your authentication request, though.

Just to make sure, are you setting the user-agent option as you construct the snoowrap instance? e.g.

new snoowrap({
  user_agent: 'put the custom user-agent string here',
  client_id: 'foo',
  client_id: 'bar',
  refresh_token: 'baz'
})

from snoowrap.

mschwartz avatar mschwartz commented on August 21, 2024

image

I removed the client_id, etc., strings for security reasons :)

from snoowrap.

not-an-aardvark avatar not-an-aardvark commented on August 21, 2024

I can reproduce this. It seems like the user-agent header gets ignored when making requests from browsers.

from snoowrap.

mschwartz avatar mschwartz commented on August 21, 2024

Awesome.

Now the question is if you can figure out how to override the header or contact Reddit and ask about the redirect.

from snoowrap.

mschwartz avatar mschwartz commented on August 21, 2024

Also, I appreciate your patience and looking at this.

from snoowrap.

not-an-aardvark avatar not-an-aardvark commented on August 21, 2024

I decided to make another ticket for the user-agent issue (see #33) and close this one, since the original issue of const not working in safari should be fixed in the next update.

from snoowrap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.