有没有办法让用户使用来自Snapkit登录web api的Access令牌的Bitmoji?

问题描述 投票:0回答:2

我正在尝试使用snapkit登录web api进行混合应用程序。我已经成功拦截了redirectURL中的访问令牌。我想知道是否有办法让用户Bitmoji使用此access_token以及login.js中的函数或http get调用?

Api docs:https://docs.snapchat.com/docs/login-kit/#web

目前我在app.component.ts上的深层链接功能中有access_token。我试图使用navController推送到新页面并将access_token作为参数传入,但这在尝试获取用户信息时没有帮助。

在此先感谢您的帮助。

这是Deeplinking,我使用myapp:// settings-set /作为URL重定向拦截access_token,并尝试使用匹配的url推送新页面。

platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();

      this.deeplinks.routeWithNavController(this.nav,{
        '/settings-set/:token': SettingsSetPage
      }).subscribe((match) => {
        // match.$route - the route we matched, which is the matched entry from the arguments to route()
        // match.$args - the args passed in the link
        // match.$link - the full link data

        this.nav.push(SettingsSetPage, {
          args: match
        });
        console.log('Successfully matched route', match.$args);
      },
      (nomatch) => {
        // nomatch.$link - the full link data
        console.error('Got a deeplink that didn\'t match', nomatch);
      });
    });

  }

在设置集页面中,我使用以下方式接收参数:

this.args = navParams.get('args');

console.log("this is args", JSON.stringify(this.args));

但不知道如何使用这些信息来获取用户信息

ionic-framework ionic3 hybrid-mobile-app snapchat
2个回答
1
投票

Bitmoji API有时会非常混乱。我建议使用Passport,一个用于OAuth的Node JS工具,以及Ionic框架。 Snapchat有一个guide,解释了如何使用护照从用户的Snapchat配置文件中获取特定字段,例如用户名和Bitmoji头像。您可以按照this教程学习如何将Node JS集成到现有的离子应用程序中。

总而言之,请尝试按照以下步骤操作:

  1. 将Node JS集成到您现有的离子应用程序中
  2. 安装Passport并按照Snapchat的指南从用户的个人资料中获取特定字段

0
投票

是的,就像莫拉所说,你可以使用护照,这将使你的生活更轻松。我们还有一个运行here的示例护照应用程序:

从你提供的上下文看来,你似乎已经生成了code而不是access_token。从重定向URL获取代码后,您需要使用代码生成访问令牌。检查2.5 here部分。

获得访问令牌后,您可以使用它来请求信息。这方面的关键在于正确设置“范围”。要获得Bitmoji头像,请确保至少将范围设置为:

var scope = ['https://auth.snapchat.com/oauth2/api/user.bitmoji.avatar'];

希望这可以帮助!

© www.soinside.com 2019 - 2024. All rights reserved.