Updated angel_auth_oauth2
This commit is contained in:
parent
2014c95105
commit
c94ec5f3fe
2 changed files with 22 additions and 14 deletions
|
@ -20,17 +20,18 @@ var options = ExternalAuthOptions(
|
|||
/// Github doesn't properly follow the OAuth2 spec, so here's logic to parse their response.
|
||||
Map<String, dynamic> parseParamsFromGithub(MediaType contentType, String body) {
|
||||
if (contentType.type == 'application') {
|
||||
if (contentType.subtype == 'x-www-form-urlencoded')
|
||||
if (contentType.subtype == 'x-www-form-urlencoded') {
|
||||
return Uri.splitQueryString(body);
|
||||
else if (contentType.subtype == 'json')
|
||||
} else if (contentType.subtype == 'json') {
|
||||
return (json.decode(body) as Map).cast<String, String>();
|
||||
}
|
||||
}
|
||||
|
||||
throw FormatException(
|
||||
'Invalid content-type $contentType; expected application/x-www-form-urlencoded or application/json.');
|
||||
}
|
||||
|
||||
main() async {
|
||||
void main() async {
|
||||
// Create the server instance.
|
||||
var app = Angel();
|
||||
var http = AngelHttp(app);
|
||||
|
@ -60,7 +61,7 @@ main() async {
|
|||
|
||||
// This function is called when the user ACCEPTS the request to sign in with Github.
|
||||
(client, req, res) async {
|
||||
var response = await client.get('https://api.github.com/user');
|
||||
var response = await client.get(Uri.parse('https://api.github.com/user'));
|
||||
var ghUser = json.decode(response.body);
|
||||
var id = ghUser['id'] as int;
|
||||
|
||||
|
|
|
@ -1,17 +1,24 @@
|
|||
name: angel_auth_oauth2
|
||||
description: angel_auth strategy for OAuth2 login, i.e. Facebook, Github, etc.
|
||||
version: 2.1.0
|
||||
author: Tobe O <thosakwe@gmail.com>
|
||||
version: 3.0.0
|
||||
#author: Tobe O <thosakwe@gmail.com>
|
||||
publish_to: none
|
||||
environment:
|
||||
sdk: ">=2.10.0 <2.12.0"
|
||||
sdk: ">=2.10.0 <3.0.0"
|
||||
homepage: https://github.com/angel-dart/auth_oauth2.git
|
||||
dependencies:
|
||||
angel_auth: # ^2.0.0
|
||||
path: ../auth
|
||||
angel_framework: # ^2.0.0-alpha
|
||||
path: ../framework
|
||||
http_parser: ^3.0.0
|
||||
oauth2: ^1.0.0
|
||||
angel_auth:
|
||||
git:
|
||||
url: https://github.com/dukefirehawk/angel.git
|
||||
ref: sdk-2.12.x
|
||||
path: packages/auth
|
||||
angel_framework:
|
||||
git:
|
||||
url: https://github.com/dukefirehawk/angel.git
|
||||
ref: sdk-2.12.x
|
||||
path: packages/framework
|
||||
http_parser: ^4.0.0
|
||||
oauth2: ^2.0.0
|
||||
dev_dependencies:
|
||||
logging: ^0.11.0
|
||||
logging: ^1.0.0
|
||||
pedantic: ^1.0.0
|
Loading…
Reference in a new issue