From 8b5438959de157719a01b7afd6470bf5482d7006 Mon Sep 17 00:00:00 2001
From: daniel furaev <daniel.furaev@stud.hs-hannover.de>
Date: Mon, 6 Feb 2023 18:33:37 +0100
Subject: [PATCH] generate auth token hoffentlich

---
 lib/searchpage.dart       | 1 +
 lib/services/spotify.dart | 9 +++++----
 lib/widgets/navbars.dart  | 7 +++----
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/lib/searchpage.dart b/lib/searchpage.dart
index 16ec92b..9ec48e8 100644
--- a/lib/searchpage.dart
+++ b/lib/searchpage.dart
@@ -22,6 +22,7 @@ class SearchPage extends State<StateSearcgPage> {
 
   @override
   Widget build(BuildContext context) {
+    spotifyApi.generateAuthToken();
     return Scaffold(
         body: Padding(
             padding: const EdgeInsets.all(10.0),
diff --git a/lib/services/spotify.dart b/lib/services/spotify.dart
index 735c90c..1518fd0 100644
--- a/lib/services/spotify.dart
+++ b/lib/services/spotify.dart
@@ -25,10 +25,10 @@ class Spotify {
       final response = await http.post(
         Uri.parse('https://accounts.spotify.com/api/token'),
         body: {
-          'grant_type': 'password',
-          'username': email,
-          'password': password,
-          'scope': scope,
+          "grant_type": "authorization_code",
+          'client_id': "$clientId",
+          "client_secrete": "$clientSecret",
+          'scope': "$scope",
         },
         headers: {
           'Authorization': encoded,
@@ -37,6 +37,7 @@ class Spotify {
       final responseJson = json.decode(response.body);
 
       authToken = responseJson['access_token'];
+      print(authToken);
     } catch (e) {
       // TODO: Handle Error
     }
diff --git a/lib/widgets/navbars.dart b/lib/widgets/navbars.dart
index 782c877..f6c3881 100644
--- a/lib/widgets/navbars.dart
+++ b/lib/widgets/navbars.dart
@@ -22,12 +22,11 @@ class SettingsDrawer extends StatelessWidget {
         padding: EdgeInsets.zero,
         children: [
           UserAccountsDrawerHeader(
-            accountName: user['display_name'],
-            accountEmail: user['email'],
+            accountName: Text("Ambient"),
+            accountEmail: Text("ambient.spotify@gmail.com"),
             currentAccountPicture: CircleAvatar(
               child: ClipOval(
-                  child: Image.network(
-                user['images'][0]['url'],
+                  child: Image.network("https://upload.wikimedia.org/wikipedia/commons/thumb/c/cf/Angular_full_color_logo.svg/1200px-Angular_full_color_logo.svg.png",
                 width: 90,
                 height: 90,
                 fit: BoxFit.cover,
-- 
GitLab