gmail卡服务中的密码类型字段 [英] Password type field in gmail card service

查看:89
本文介绍了gmail卡服务中的密码类型字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,在gmail应用程序脚本中,我们没有任何添加密码类型字段的选项.

Right now, in gmail appscript we don't have any option to add a password type field.

Gmail卡附加服务具有很好的显示任何内容的能力.我们可以与任何具有基本REST API的应用程序集成.我们需要通常需要密码类型字段的身份验证.

Gmail Card Service for add-on has a very good ability to show any thing in it. We can integrate with any app which has basic REST api. We need authentication for that which commonly need password type field.

是否可以解决显示密码类型字段的问题?

Any work around to show password type field?

推荐答案

到目前为止,Gmail附加组件中不支持密码字段.

As of now, there is no support for password field in Gmail add-on.

但是我们可以为此建立一个hack.我希望仅在注册表中需要密码.因此,我们可以使用HTML构建注册表单,并且可以通过授权操作提供注册表单.

But we can build a hack for it. I hope password is needed only in registration forms. So, we can build a registration form using HTML and that can be served through authorization action.

CardService.newAuthorizationAction().setAuthorizationUrl(loginUrl)

在这里,在Web服务器中进行主机注册HTML,并在上述代码段中将该URL作为"loginUrl"传递.我们必须为注册/注册按钮提供AuthorizationAction.因此,当用户单击此按钮时,将启动一个新的弹出页面,用户在提交时将提供用户名,密码等...,我们可以对所有表单数据进行编码,然后通过以下方式将其传递给父级Gmail加载项将其重定向到脚本重定向URL,您可以生成一个加载项.一旦重定向到脚本URL,我们的附加代码中就会有一个回调,您可以从中获取从注册HTML页面编码的表单字段.

Here, host registration HTML in a web server and pass this URL as "loginUrl" in the above snippet. We have to supply AuthorizationAction for the signup/register button. So, when the user clicks on this button, a new popup page is launched, the user will give the username, password, etc... onsubmit, we can encode all the form data and pass it to the parent Gmail add-on by redirecting it to a script redirection URL which you can generate an add-on. Once the redirection to the script URL comes, there will be a callback in our add-on code from there you can get the form fields which were encoded from registration HTML page.

function generateNewStateToken(callbackName, payload) {
        return ScriptApp.newStateToken()
        .withMethod(callbackName)
        .withArgument("payload", JSON.stringify(payload))
        .withTimeout(3600)
        .createToken();
    }

function getRedirectURI() {
    return "https://script.google.com/macros/d/" + ScriptApp.getScriptId() + "/usercallback";
  }

var state = generateNewStateToken("registerCallback", {"signup": true});
var reg_url = <reg_url> + "?redirect_uri=" + getRedirectURI() + "&state=" + state;

function registerCallback(cbResp) {
 // to access payload which passed in state token: cbResp.parameter.payload;

// in the html serialize all the form fields or data which you want to pass to plugin as query params like: <redirect_uri>?form_data=<encoded_data>&state=<state>

//Note: here the registration HTML page should parse the URL to get the state & redirect_uri from URL.

// to access form_data: cbResp.parameter.form_data

}

我希望这会对您有所帮助.这就是我们现在进行注册/登录流程的方式.

I hope this will help you. This is how we are doing the signup/signin flow now.

这篇关于gmail卡服务中的密码类型字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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