如何使用React Native App Auth获取个人资料数据和电子邮件?

时间:2019-10-09 12:41:48

标签: react-native google-oauth google-oauth2

我在使用react-native-app-auth(https://www.npmjs.com/package/react-native-app-auth)来获取个人资料数据(givenName等)和电子邮件时遇到问题,在文档中没有获取信息的方法。

这是我的剧本:

    import React, { Component } from 'react';
        import { Button, View, Text } from 'react-native';
        import { authorize } from 'react-native-app-auth';

const config = {
  issuer: 'https://accounts.google.com',
  clientId: '1552xxxx.apps.googleusercontent.com',
  redirectUrl: 'com.trylogin:/oauth2callback',
  scopes: ['profile','email']
};

        export default class App extends Component {
          loginGoogle() {
            authorize(config).then(res =>{
              console.log(res);
            }, err => {
              console.log(err);
            });
          }

          render() {
            return (
              <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
                <Text>App Screen</Text>
                <Button
                  title="google"
                  onPress={() => this.loginGoogle()}
                />
              </View>
            );
          }
        }

请任何人帮助我获取个人资料数据和电子邮件。谢谢

0 个答案:

没有答案