我的应用程序中的Google云打印API集成 [英] Google cloud print API integration in my application

查看:135
本文介绍了我的应用程序中的Google云打印API集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Google云打印集成到Android应用程序中.我不想通过Print框架进行操作,因为我的要求是直接从应用程序进行打印,而无需任何选择过程.

为此,我已经集成了Google身份验证并为此生成了访问令牌.我正在尝试使用access_token加载打印机列表,但始终出现错误.

以下是我的API调用详细信息:

URL: https://www.google.com/cloudprint/search

类型:POST

标题:

授权:OAuth ACCESS_TOKEN

Content-Type:应用程序/json

错误消息是:

<HTML>
    <HEAD>
        <TITLE>User credentials required</TITLE>
    </HEAD>
    <BODY BGCOLOR="#FFFFFF" TEXT="#000000">
        <H1>User credentials required</H1>
        <H2>Error 403</H2>
    </BODY>
</HTML>

任何帮助表示赞赏.

解决方案

创建一个Google网上论坛.通过直接邀请添加成员:

  1. 您的gmail帐户(gmail电子邮件地址)
  2. 提供访问令牌的Google服务帐户(服务帐户电子邮件地址)

然后按照以下步骤操作:

  1. 转到google.com/cloudprint
  2. 选择打印机,然后单击共享"选项卡.在邀请人员下添加以下成员:
    • google服务帐户的电子邮件地址
    • google网上论坛的电子邮件地址(例如xyz@googlegroups.com)

然后尝试调用GCP API.它将完美运行.

I am trying to integrate Google cloud print in Android Application. I do not want to do it through Print framework as my requirement is to directly print from application without any selection process.

For this, I have integrate Google authentication and generate access token for that. I am trying to load printer list using access_token but getting error all the time.

Following are my API call details:

URL : https://www.google.com/cloudprint/search

Type : POST

Header :

Authorization : OAuth ACCESS_TOKEN

Content-Type : application/json

Error message is:

<HTML>
    <HEAD>
        <TITLE>User credentials required</TITLE>
    </HEAD>
    <BODY BGCOLOR="#FFFFFF" TEXT="#000000">
        <H1>User credentials required</H1>
        <H2>Error 403</H2>
    </BODY>
</HTML>

Any help appreciated.

解决方案

Create a google group. Add members by direct invite:

  1. Your gmail account (gmail email address)
  2. Your google service account from which access token was furnished (service account email address)

Then follow the below steps:

  1. Go to google.com/cloudprint
  2. Select your printer and click Share tab. Add following members under invite people:
    • google service account email address
    • google group email address ( eg, xyz@googlegroups.com)

Then try calling GCP APIs. It will work perfectly.

这篇关于我的应用程序中的Google云打印API集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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