From e97befd412351c5c3736bdb49c2d2d51156452b0 Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Mon, 27 Jan 2020 13:24:01 +0800 Subject: [PATCH] refactor: oauth process --- lib/models/auth.dart | 6 +++--- lib/utils/constants.dart | 6 ------ 2 files changed, 3 insertions(+), 9 deletions(-) delete mode 100644 lib/utils/constants.dart diff --git a/lib/models/auth.dart b/lib/models/auth.dart index 103a296..b927810 100644 --- a/lib/models/auth.dart +++ b/lib/models/auth.dart @@ -12,11 +12,12 @@ import 'package:url_launcher/url_launcher.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import '../utils/constants.dart'; import '../utils/utils.dart'; import 'account.dart'; import 'gitlab.dart'; +const clientId = 'df930d7d2e219f26142a'; + class PlatformType { static const github = 'github'; static const gitlab = 'gitlab'; @@ -64,14 +65,13 @@ class AuthModel with ChangeNotifier { // Get token by code final res = await http.post( - 'https://github.com/login/oauth/access_token', + 'https://git-touch-oauth.now.sh/api/token', headers: { HttpHeaders.acceptHeader: 'application/json', HttpHeaders.contentTypeHeader: 'application/json', }, body: json.encode({ 'client_id': clientId, - 'client_secret': clientSecret, 'code': uri.queryParameters['code'], 'state': _oauthState, }), diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart deleted file mode 100644 index 9b7ff5c..0000000 --- a/lib/utils/constants.dart +++ /dev/null @@ -1,6 +0,0 @@ -// These keys are for development, not the production keys -// You can also create OAuth App at https://github.com/settings/applications/new -// to get your own keys and replace these ones - -var clientId = '9b7d1cc04a1db5710767'; -var clientSecret = '710e085908dde6a8b55f7a9dc447ad5c0c5617d1';