GithubHelp home page GithubHelp logo

Comments (10)

scrogson avatar scrogson commented on July 24, 2024

Hi @ponty96 can you please provide some context for this error?

from oauth2.

ponty96 avatar ponty96 commented on July 24, 2024

Yeah. So I'm using that example and I'm trying to implement Google Oauth. So when I visit http://localhost:4000/google it redirects to the a Google URL and I get that error on the page. Which I should instead get the page where I sign in to google

from oauth2.

scrogson avatar scrogson commented on July 24, 2024

I just tried the example app and it worked fine for me. The error you are getting seems unrelated to the example app or this library.

Did you export the necessary environment variables for you Google application for use in the example app?

If not, they are:

GOOGLE_CLIENT_ID="<your-client-id>"
GOOGLE_CLIENT_SECRET="<your-client-secret>"
GOOGLE_REDIRECT_URI="http://lvh.me:4000/auth/google/callback"

Other than that, I'm not sure what else it could be.

Doing a quick search for the error you provided lead me to this post: http://www.incrediblelab.com/dns-probe-finished-bad-config-error-fixed/

Not sure if that helps...let me know.

from oauth2.

ponty96 avatar ponty96 commented on July 24, 2024

yeah. it was a silly error from my end

from oauth2.

ponty96 avatar ponty96 commented on July 24, 2024

But I'm getting this now, this is after I accept on the google authorize page and i'm using the same credentials for the javascript client which is working
screen shot 2016-12-08 at 12 03 27 pm

from oauth2.

tsubery avatar tsubery commented on July 24, 2024

@ponty96 If I remember correctly, google requires different credentials for different clients (front/backend). When you create new credentials, they ask what type of client do you need it for. You can try creating new credentials and see if that works.

from oauth2.

ponty96 avatar ponty96 commented on July 24, 2024

@tsubery I've tried doing that... Same issue

from oauth2.

johannesE avatar johannesE commented on July 24, 2024

I might have the same issue with github:
After getting the token, my client looks like this:
pry(1)> client
%OAuth2.Client{authorize_url: "https://github.com/login/oauth/authorize", client_id: "foo", client_secret: "foo", headers: [], params: %{}, redirect_uri: "http://localhost:4000/auth/github/callback", site: "https://api.github.com", strategy: GitHub, token: %OAuth2.AccessToken{access_token: "{\"access_token\":\"foo\",\"token_type\":\"bearer\",\"scope\":\"public_repo,user\"}", expires_at: nil, other_params: %{}, refresh_token: nil, token_type: "Bearer"}, token_method: :post, token_url: "https://github.com/login/oauth/access_token"}

When I try a request:
pry(2)> OAuth2.Client.get!(client, "/user").body
"{\"message\":\"Bad credentials\",\"documentation_url\":\"https://developer.github.com/v3\"}"

Might it be, that the access_token is too deply nested? Is it supposed to look like that?

EDIT: After looking through the code, I am pretty sure that it's not supposed to look like this.
The response is used to create a token. It is probably treated as a binary instead of a map.

def new(token) when is_binary(token) do
    new(%{"access_token" => token})
end
def new(response) when is_map(response) do
    {std, other} = Map.split(response, @standard)
...

FYI: I am using the standard OAuth2.Client.get_token!(client(), params, headers) to get my token.

from oauth2.

scrogson avatar scrogson commented on July 24, 2024

@johannesE did you set the configuration for the serializers as outlined in the README? It looks like the access token came back fine but wasn't properly parsed.

config :oauth2, :serializers, %{
  "application/json" => Poison
}

from oauth2.

johannesE avatar johannesE commented on July 24, 2024

Oh my god, that was it. Sorry for wasting your time. Thank you for the help!

EDIT: To be precise, I had the following in there. It was unable to parse that properly.

config :oauth2, 
  serializers: %{ 
    "application/vnd.api+json" => Poison, 
    #"application/xml" => MyApp.XmlParser, 
  } 

After removing the vnd.api+, it worked.

from oauth2.

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.