Question

Is it possible to share a GCP printer with a Google API service account (https://developers.google.com/accounts/docs/OAuth2ServiceAccount)?

I tried to share the printer with the client email address (id@developer.gserviceaccount.com), but the printer is not shown in the response to the API call /search. Calling /submit leads to an error (User has no access)

Was it helpful?

Solution 2

I believe you are encountering the "is pending" problem.
Namely, you did share your printer with the id@developer.gserviceaccount.com account but the other user (in this case id@developer.gserviceaccount.com) has to accept the invitation to share the printer.

You can check this by issuing the /print request and you will see an

"is_pending": true

element in the access section for your user (id@developer.gserviceaccount.com) in this case.

Needless to say that accounts that have this element set to true cannot print - hence the "User is not authorized." message.
I know no way to accept the invitation for the given service account however there is a workaround:

  1. You can create a private google group with an account that can accept shared printers (e.g. your gmail account).
  2. Then you add the service account ("id@developer.gserviceaccount.com") to the group et voila. You can print with the service account ;).

When you share the printer you must share it with the google group (use the group's email address which you can find somewhere in the group management console) and the group manager (e.g. your gmail account) must accept the invitation for the whole group.

More info on how to create the group can be found here.
I have tried this with a GAE service account and it works. If you need any clarification do not hesitate to ask. Good luck.

OTHER TIPS

As you yourself shared the printer with the service account, we can assume you know the "Printer ID" of the printer to which the service account has been invited.

Have the service account call the /processinvite request, with these (mandatory) parameters:

  • printerid = the-known-printer-id
  • accept = true

After that, the printer will appear in /search

Happy printing!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top