Comments (10)
Hi @ponty96 can you please provide some context for this error?
from oauth2.
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.
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.
yeah. it was a silly error from my end
from oauth2.
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
from oauth2.
@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.
@tsubery I've tried doing that... Same issue
from oauth2.
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.
@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.
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)
- Not able get access token with ClientCredentials strategy HOT 10
- Support For HTTP Basic Auth hasn't (yet) been officially released HOT 3
- Global Serializer Registration HOT 1
- QuickBooks with AuthCode strategy doesn't like client_id with basic auth HOT 5
- Allow authorizing without basic auth header HOT 7
- Issue with refresh_token HOT 5
- Tuple {:option, :server_only, :honor_cipher_order} being returned for error reason HOT 2
- OAuth2.Client.get_token!/2 not deserializing token response HOT 6
- Support for logging out of identity provider HOT 1
- OTP 23 OAuth2.Error HOT 2
- Oauth2.Client.get_token not working for Google HOT 5
- No Case clause matching when setting token_method HOT 2
- Defaults to application/json when content-type header is not present HOT 4
- PKCE flow? HOT 3
- %OAuth2.AccessToken{} have not parsed well for Google auth usage HOT 4
- "Accept" header should be "application/json" when getting token HOT 9
- I want to curse and curse. A lot HOT 1
- How to get user_id or username in "callback"? HOT 2
- OAuth2.Client.get_token fails for Octa servers HOT 5
- dialyzer problem HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oauth2.