问题
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.
回答1:
Create a google group. Add members by direct invite:
- Your gmail account (gmail email address)
- Your google service account from which access token was furnished (service account email address)
Then follow the below steps:
- Go to google.com/cloudprint
- 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.
来源:https://stackoverflow.com/questions/52968277/google-cloud-print-api-integration-in-my-application