小编Jow*_*wet的帖子

Flutter:Oauth2 - 重定向 uri 的问题

我想在我的 Flutter 应用程序中设置 Spotify API 的 oAuth 身份验证。我选择了 flutter_web_auth 0.1.1 包。到目前为止,我已经设法让用户可以登录到 Spotify。登录后,用户应该被重定向回我的应用程序。那行不通。Spotify 总是将用户重定向到另一个网站,而不是返回到应用程序。用户登录后如何关闭 WebView 并将用户重定向到我的应用程序?

import 'package:flutter/material.dart';
import 'package:flutter_web_auth/flutter_web_auth.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    authenticate();
  }

  void authenticate() async {
    // Present the dialog to the user
    final result = await FlutterWebAuth.authenticate(
      url:
          "https://accounts.spotify.com/de/authorize?client_id=78ca499b2577406ba7c364d1682b4a6c&response_type=code&redirect_uri=https://partyai/callback&scope=user-read-private%20user-read-email&state=34fFs29kd09",
      callbackUrlScheme: "https://partyai/callback",
    );

// Extract token from resulting url
    final token = Uri.parse(result).queryParameters['token'];
    print('token');
    print(token);
  } …
Run Code Online (Sandbox Code Playgroud)

oauth spotify oauth-2.0 flutter

1
推荐指数
2
解决办法
6896
查看次数

Flutter:如何将原生 SDK(Spotify Android SDK)添加到应用程序中?

我想编写一个访问 Spotify Android SDK 的包。我正在尝试添加身份验证。那是行不通的。我没能打开登录屏幕。我是否需要在 dart 代码中添加视图(如下所述: https: //60devs.com/how-to-add-native-code-to-flutter-app-using-platform-views-android.html) ?

镖:

...
void initPlatformState() async {
    try {
      String test = await Nativecode05.spotifyTest;
      print(test);
    } on PlatformException {
      platformVersion = 'Failed';
    }
  }
...
Run Code Online (Sandbox Code Playgroud)

包裹:

import 'dart:async';

import 'package:flutter/services.dart';

class Nativecode05 {
  static const MethodChannel _channel = const MethodChannel('nativecode05');

  static Future<String> get spotifyTest async {
    final String version = await _channel.invokeMethod('spotifyTest');
    return version;
  }
}
Run Code Online (Sandbox Code Playgroud)

包中的Java代码:

package example.com.nativecode05;

import io.flutter.Log;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import …
Run Code Online (Sandbox Code Playgroud)

java android spotify flutter

1
推荐指数
1
解决办法
1810
查看次数

多个 require 函数的问题(RequireJS 和 ArcGIS JS API)

我目前正在寻找一种在项目中使用模块加载器RequireJSArcGIS JS API的方法。根据文档,可以加载ArcGIS JS API的模块,如以下代码片段所示:

require(["esri/config", "esri/Map", "esri/views/MapView"], function (
  esriConfig,
  Map,
  MapView
) {
  //...
});
Run Code Online (Sandbox Code Playgroud)

问题是,如果我想从ArcGIS JS API加载模块,它实际上调用了RequireJS的Require函数:

在此输入图像描述

但它应该加载 ArcGIS JS API 中定义的 require 函数:

在此输入图像描述

RequireJS 找不到 ArcGIS JS API 的模块,因此在控制台中抛出错误:

在此输入图像描述

我的项目只支持ES5。因此,我无法使用像esri-loader这样的节点库。

javascript arcgis requirejs arcgis-js-api

1
推荐指数
1
解决办法
295
查看次数