如何使用从Snapchat收到的AccessToken来获取UserData? [英] How to use AccessToken received from Snapchat to fetch UserData?

查看:248
本文介绍了如何使用从Snapchat收到的AccessToken来获取UserData?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用snapkit登录文档(WEB)之后,我实现了服务器端代码,并且能够为用户获取访问令牌(

Following snapkit Login Documentation (WEB), I implemented server side code and am able to obtain Access Token for the user (Section 2.5 at https://docs.snapchat.com/docs/tutorials/login-kit/web/ ).

如何使用此令牌实际获取用户数据?没有提到必须为ex做些什么.用访问令牌发出POST/GET请求?我认为这是该过程中最关键的部分,文档中似乎缺少此部分.

How do I use this token to actually get user data? There is no mention of what one must do for ex. make a POST / GET request with the Access Token? This I think is the most critical part of the process, and it seems to be missing from the documentation.

我也尝试使用SCSDKLoginClient.getAccessToken(),我能够从Snapchat检索已登录用户的令牌.但是,我也找不到任何有关如何从那里获取用户数据的文档.唯一提及的是回调fetchUserData(),但那里也没有用于Token的字段.

I also tried using SCSDKLoginClient.getAccessToken(), I am able to retrieve token from Snapchat for the user who has logged in. However, I can't find any documentation on how to get user data there either. The only mention is that of a callback fetchUserData() but there's no field for Token there either.

推荐答案

在经过长时间的研究后找到答案的同时,我还回答了自己的问题,这要归功于Snapchat的支持.

Answering my own question as I found the answer after long research, thanks to Snapchat Support.

按照以下说明获取访问令牌后,请按照以下步骤获取用户信息.

Once you get the Access token by following documentation, follow below steps to get user info.

(将ACCESS_TOKEN替换为您自己的访问令牌.)

(Swap out ACCESS_TOKEN for your own access token.)

URL: "https://kit.snapchat.com/v1/me"
Headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer ' + access_token}
jSON_body= {"query":"{me{displayName bitmoji{avatar} externalId}}"}

这应该返回如下的jSON结果以及用户信息:

This should return jSON result like the following with the user information:

{
    "data": {
        "me": {
            "displayName": "DISPLAY_NAME",
            "bitmoji": {
                "avatar": "URL_BITMOJI_IMAGE"
            },
            "externalId": "EXTERNAL_ID"
        }
    },
    "errors": []
}

这篇关于如何使用从Snapchat收到的AccessToken来获取UserData?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆