msa7 / multi_auth Goto Github PK
View Code? Open in Web Editor NEWStandardized multi-provider OAuth authentication
License: MIT License
Standardized multi-provider OAuth authentication
License: MIT License
Trying to implement GitHub authentication with Amber but I keep an error over VK this during multi_auth.authorize_uri
.
This is my initialization code:
MultiAuth.config("github", GITHUB_CLIENT_ID, GITHUB_SECRET_KEY)
multi_auth = MultiAuth.make("github", "/callback")
multi_auth.authorize_uri
This is the output error from trying to build with amber watch
:
multi_auth = MultiAuth.make("github", "/callback").authorize_uri # initialize engine
^~~~~~~~~~~~~
in lib/multi_auth/src/multi_auth/engine.cr:20: instantiating 'authorize_uri(Nil)'
def authorize_uri(scope = nil)
^~~~~~~~~~~~~
in lib/multi_auth/src/multi_auth/engine.cr:21: instantiating 'MultiAuth::Provider+#authorize_uri(Nil)'
provider.authorize_uri(scope)
^~~~~~~~~~~~~
in lib/multi_auth/src/multi_auth/providers/vk.cr:4: instantiating 'client()'
client.get_authorize_uri(@scope)
^~~~~~
in lib/multi_auth/src/multi_auth/providers/vk.cr:96: no argument named 'auth_scheme'
Matches are:
- OAuth2::Client.new(host : String, client_id : String, client_secret : String, port : Int32 | ::Nil = nil, scheme = "https", authorize_uri = "/oauth2/authorize", token_uri = "/oauth2/token", redirect_uri : String | ::Nil = nil)
OAuth2::Client.new(
I followed all the relevant integration examples and not even referring to VK at any point.
Any ideas?
Hi there,
I'm new to crystal and trying to spin up an oauth client. I have it working, but I'm running into trouble persisting my access_token
. I want to access the string property of the access_token
string instance method and use it to pull the string out of the instance. But, because the User class's access_token
property can be nil
, crystal won't let me access the property access_token
for the type (OAuth2::AccessToken | Nil)
Forgive me if this is a novice question.
Some time ago I forked multi_auth, wanting to add Spotify support. But then I realized that maybe it's better to just allow developer to add their own provider, without the need to fork the project.
The outline commit for that is here: katafrakt@78ab475 Of course, this still requires testing and documentation, at least. I can do that and prepare a pull request, but since it's a new feature, I wanted to discuss it first.
Hi
Can you please add the support for Apple as a sign in provider?
Are you interested in this? Would you accept such a pull request?
The problem is twitter uses OAuth 1.0 (not 2.0), but this does not violate shard name. But will need to change the interfaces though.
you should remove the tag and release a v1.1.0
instead
I'm seeing this error come up a bit in my app. It looks like google doesn't always send all of the requested data back. So when the json
doesn't have a specific key, it blows up here instead of raising the intended error.
My OAuth keys for google are now saying expired. When I search for a solution, they say we're supposed to be using refresh tokens. How do I use refresh tokens with this sign in? The user connects with google, then is MultiAuth supposed to fetch a fresh token and then I'm supposed to save that or something? I'm not understanding how that flow is supposed to work in this case.
If the Twitter provider isn't setup properly, you won't get back a valid user json on this line. Since there's no built-in logging here, the only thin you know is of the missing id
attribute.
I had to update the code in lib/ to debug what the error was from the raw_json
{"errors":[{"message":"You currently have Essential access which includes access to Twitter API v2 endpoints only. If you need access to this endpoint, you’ll need to apply for Elevated access via the Developer Portal. You can learn more here: https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#v2-access-leve","code":453}]}
Maybe this can just catch the error, and re-raise raw_json
?
The twitter auth is a bit tricky. All of the current supported engines use OAuth2 except Twitter.
The issue is that Twitter itself gives you several different secret keys to choose from:
If you use the Access Token
and Secret
, you'll get a NilAssertionError
, but no information that actually tells you that you're plugging OAuth2 keys in to an OAuth1 provider. In this case, you need to use the "Consumer Keys".
I'm not really sure what the actionable item is here, but here's a few options:
In the google provider, there's a line:
json["urls"].as_a.each do |url|
I setup my scope authorization to just be "profile email", and it tanks on this line at the callback. Inspecting the json
at that point only has profile and email info, but no mention of a urls
key.
Hi
I tried the example given in the github page.
I used it for a google auth process.
However when the redirect_uri is called, i get the following error;
Missing hash key: "names" (KeyError)
0x559ef99d459b: fetch at /opt/crystal/src/hash.cr 124:9
0x559ef99d446d: [] at /opt/crystal/src/hash.cr 60:5
0x559ef99d4ee8: [] at /opt/crystal/src/json/any.cr 100:15
0x559ef999f175: primary? at /home/rick/DevSpace/Crystal/Kamel/lib/multi_auth/src/multi_auth/providers/google.cr 68:5
0x559ef999f06d: primary at /home/rick/DevSpace/Crystal/Kamel/lib/multi_auth/src/multi_auth/providers/google.cr 62:15
0x559ef999e3dc: build_user at /home/rick/DevSpace/Crystal/Kamel/lib/multi_auth/src/multi_auth/providers/google.cr 81:12
0x559ef999e360: user at /home/rick/DevSpace/Crystal/Kamel/lib/multi_auth/src/multi_auth/providers/google.cr 59:5
0x559ef999adac: user at /home/rick/DevSpace/Crystal/Kamel/lib/multi_auth/src/multi_auth/engine.cr 23:5
0x559ef9867c6c: ~procProc(HTTP::Server::Context, (String | Nil)) at /home/rick/DevSpace/Crystal/Kamel/lib/kemal/src/kemal/dsl.cr 10:1
0x559ef9869b1c: ~proc4Proc(HTTP::Server::Context, String) at /home/rick/DevSpace/Crystal/Kamel/lib/kemal/src/kemal/dsl.cr 10:1
0x559ef998326d: process_request at /home/rick/DevSpace/Crystal/Kamel/lib/kemal/src/kemal/route_handler.cr 255:3
0x559ef9983096: call at /home/rick/DevSpace/Crystal/Kamel/lib/kemal/src/kemal/route_handler.cr 18:7
0x559ef99e5e86: call_next at /opt/crystal/src/http/server/handler.cr 24:7
0x559ef99e5859: call at /home/rick/DevSpace/Crystal/Kamel/lib/kemal/src/kemal/static_file_handler.cr 56:9
0x559ef99e496d: call_next at /opt/crystal/src/http/server/handler.cr 24:7
0x559ef99e4450: call at /home/rick/DevSpace/Crystal/Kamel/lib/kemal/src/kemal/common_exception_handler.cr 9:9
0x559ef99e39f3: call_next at /opt/crystal/src/http/server/handler.cr 24:7
0x559ef99e0601: call at /home/rick/DevSpace/Crystal/Kamel/lib/kemal/src/kemal/common_log_handler.cr 13:35
0x559ef99820e8: call_next at /opt/crystal/src/http/server/handler.cr 24:7
0x559ef9981ccf: call at /home/rick/DevSpace/Crystal/Kamel/lib/kemal/src/kemal/init_handler.cr 11:7
0x559ef99ed80b: process at /opt/crystal/src/http/server/request_processor.cr 39:11
0x559ef99ed119: process at /opt/crystal/src/http/server/request_processor.cr 16:3
0x559ef99e75e0: handle_client at /opt/crystal/src/http/server.cr 191:5
0x559ef986b293: ~procProc(Nil) at /home/rick/DevSpace/Crystal/Kamel/lib/kemal/src/kemal/dsl.cr 10:1
0x559ef98875ce: run at /opt/crystal/src/fiber.cr 255:3
0x559ef98628a6: ~proc2Proc(Fiber, (IO::FileDescriptor | Nil)) at /opt/crystal/src/concurrent.cr 61:3
0x0: ??? at ??
like omniauth
So we don't have to write code like 😂
private def because_of_elon_musk
case provider.downcase
when "x" then "twitter"
else
provider.downcase
end
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.