7i11 / simple_oauth2 Goto Github PK
View Code? Open in Web Editor NEWThis project forked from virtan/simple_oauth2
Simple erlang OAuth2 client module for any http server framework (Google, Facebook, Yandex, Vkontakte are preconfigured)
This project forked from virtan/simple_oauth2
Simple erlang OAuth2 client module for any http server framework (Google, Facebook, Yandex, Vkontakte are preconfigured)
simple_oauth2 ============== Simple OAuth2 client for any http server framework Inspired by and based on https://github.com/dvv/social Preconfigured to authorize users of Google, Facebook, Yandex, Vkontakte, Mail.ru Usage -------------- 1. Create OAuth2 web site app keys at Google: https://code.google.com/apis/console/b/0/ Facebook: https://developers.facebook.com/apps/ Yandex: https://oauth.yandex.ru/client/new Vkontakte: http://vk.com/dev 2. Integrate into you http server framework Example for MochiWeb (https://github.com/mochi/mochiweb): SocNets = simple_oauth2:customize_networks(simple_oauth2:predefined_networks(), [ {<<"google">>, [ {client_id, <<"GOOGLE_CLIENT_ID">>}, {client_secret, <<"GOOGLE_CLIENT_SECRET">>} ]}, {<<"yandex">>, [ {client_id, <<"YANDEX_CLIENT_ID">>}, {client_secret, <<"YANDEX_CLIENT_SECRET">>} ]}, {<<"vkontakte">>, [ {client_id, <<"VK_CLIENT_ID">>}, {client_secret, <<"VK_CLIENT_SECRET">>} ]}, {<<"facebook">>, [ {client_id, <<"FB_CLIENT_ID">>}, {client_secret, <<"FB_CLIENT_SECRET">>} ]}, {<<"mailru">>, [ {client_id, <<"MR_CLIENT_ID">>}, {client_secret, <<"MR_CLIENT_SECRET">>}, {client_secret_key, <<"MR_CLIENT_SECRET_KEY">>} ]} ]), UrlPrefix = iolist_to_binary([atom_to_list(Req:get(scheme)), "://", Req:get_header_value("host")]), case simple_oauth2:dispatcher(list_to_binary(Req:get(raw_path)), UrlPrefix, SocNets) of {redirect, Where} -> Req:respond({302, [{"Location", simple_oauth2:gather_url_get(Where)}], []}); {send_html, HTML} -> Req:ok({"text/html; charset=utf-8", HTML}); {ok, AuthData} -> Req:ok({"text/plain; charset=utf-8", io_lib:format("~p~n", [AuthData])}); {error, Class, Reason} -> Req:ok({"text/plain; charset=utf-8", io_lib:format("Error: ~p ~p~n", [Class, Reason])}) end. 3. Start ssl and inets erlang applications before You can easily add more social networks (see simple_oauth2:predefined_networks()) with OAuth2 authorization. Known issues (TODO) -------------- 1. Support of GitHub, Paypal is upcoming 2. Vk doesn't provide email 3. Yandex doesn't provide picture License (MIT) -------------- Copyright (c) 2013 Igor Milyakov <[email protected]> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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.