简体   繁体   English

在flutter中使用graphql注册时如何获取令牌

[英]how to get token when sign up using graphql in flutter

hello i am trying to get the token value when user is signing up.您好,我正在尝试在用户注册时获取令牌值。 i am running mutation query for signing up a new user but my problem is i don't know how to get the token when sign up is successful.我正在运行突变查询以注册新用户,但我的问题是注册成功后我不知道如何获取令牌。

this is the api endpoint https://agro-e-commerce.herokuapp.com/graphql and this is my mutation query in graphql playground这是 api 端点https://agro-e-commerce.herokuapp.com/graphql这是我在 graphql 游乐场中的变异查询

mutation{
   signUp(data: {
   full_name:"",
user_name:"",
email:"",
phone:"",
password:"",
division:"",
region:"",
address:""
}){
token}
}

here is my code in flutter这是我颤动的代码

String query0 = """
mutation run(\$full_name: String!,\$user_name:String!,\$email:String!,
\$phone: String!,\$password: String!,\$division: String!,\$region:String!,\$address: String!){
signUp(data:{
full_name:\$full_name
user_name:\$user_name,
    email:\$email,
    phone:\$phone,
    password:\$password,
    division:\$division,
    region:\$region,
    address:\$address

}){
token
}
}

body: new Mutation(       
builder: (RunMutation runMutation, QueryResult result) {    
      return FloatingActionButton(
        child: new Icon(Icons.add),
        onPressed: () {
          runMutation({
            'user_name': 'anikkoll',
            'full_name': 'anikk karmokerkll',
            'email': 'anikjkoy78749kl@gmail.com',
            'phone': '0167605672879',
            'password': 'password',
            'division': 'barishal',
            'region': 'barishal sadar',
            'address': 'kawnia'
          });

        },
      );

    },
    options: MutationOptions(document: query0),

    onCompleted: (resultdata) {  
        print(resultdata);               
    }

i expected only token but i got this我只期望令牌,但我得到了这个

{signUp: {token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjgzYTQzMzJhLTk2OWQtNDI3Mi05OWY3LTdiOWNjN2ZlNDhkOCIsImVtYWlsIjoiYW5pa2prb3k3bDg3NDlrbEBnbWFpbC5jb20iLCJ1c2VyX25hbWUiOiJhbmlra29vbGwiLCJyb2xlIjoiQ09OU1VNRVIiLCJpbWFnZSI6bnVsbCwiZnVsbF9uYW1lIjoiYW5pa2tsIGthcm1va2Vya2xsIiwicGhvbmUiOiIwMTU3NjA1NjcyODc5IiwiYWRkcmVzcyI6Imthd25pYSIsInJlZ2lvbiI6ImJhcmlzaGFsIHNhZGFyIiwiZGl2aXNpb24iOiJiYXJpc2hhbCIsImlhdCI6MTU2MzE3ODkxOSwiZXhwIjoxNTYzNzgzNzE5fQ.qCpES_c-dtk7nr-EXqTbTWjIdj4OMqB2HBsEwFXDMlc}}

In your query, you are requesting only the token.在您的查询中,您只请求令牌。 In return, you got your token.作为回报,你得到了你的令牌。
This is the token you want now you just have to decode it.这是您现在想要的令牌,您只需对其进行解码。

"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为 graphql/flutter 设置登录令牌 - How to set up login token for graphql/flutter 如何在 flutter 中获取谷歌登录访问令牌 - How to get google sign in access token in flutter Flutter:当使用 ferry (graphql) 客户端令牌过期时如何刷新令牌? - Flutter: How to refresh token when token expires with ferry (graphql) client? 如何通过谷歌登录获取访问令牌 -- Flutter - How can i get the access token through google sign in -- Flutter 当我从 Flutter 应用程序中的开发人员控制台获得有效的客户端 ID 时,如何使用 Google 登录 Package 获取有效的服务器身份验证令牌? - How to get valid Server Auth Token using Google Sign In Package when I have a valid client ID from developers console in Flutter app? 注册/使用 firebase flutter - sign up/in using firebase flutter 注册后如何获取currentUser的uid flutter firebase - How to get uid of currentUser after sign up in flutter firebase 如何设置flutter注册 - How to set up flutter sign up 无法在 Flutter 中使用 Firebase Auth 进行注册 - Unable to sign up using Firebase Auth in Flutter 使用 Flutter 通过社交登录进行身份验证时如何获取用户详细信息? - How to get user details when authenticating with social sign in with Flutter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM