My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 3373: JWTConfigFromJSON method with imersonate feature
1 person starred this issue and may be notified of changes. Back to list
Status:  Invalid
Owner:  ----
Closed:  May 2015


Sign in to add a comment
 
Reported by mich...@soffex.co.za, May 16, 2015
Please consider adding this method to impersonate a user from a service account


// JWTConfigFromJSONWithImpersonate uses a Google Developers service account JSON key file to read
// the credentials that authorize and authenticate the requests with the ability to impersonate a user.
// Create a service account on "Credentials" page under "APIs & Auth" for your
// project at https://console.developers.google.com to download a JSON key file.
func JWTConfigFromJSONWithImpersonate(jsonKey []byte, usersEmail string, scope ...string) (*jwt.Config, error) {
	var key struct {
		Email      string `json:"client_email"`
		PrivateKey string `json:"private_key"`
	}
	if err := json.Unmarshal(jsonKey, &key); err != nil {
		return nil, err
	}
	return &jwt.Config{
		Email:      key.Email,
		PrivateKey: []byte(key.PrivateKey),
		Subject:    usersEmail,
		Scopes:     scope,
		TokenURL:   JWTTokenURL,
	}, nil
}
google.go
5.6 KB   Download
May 18, 2015
Project Member #1 david.pu...@sonymobile.com
*****************************************************************
*****                                                       *****
***** !!!! THIS BUG TRACKER IS FOR GERRIT CODE REVIEW !!!!  *****
*****                                                       *****
***** DO NOT SUBMIT BUGS FOR CHROME, ANDROID, CYANOGENMOD,  *****
***** INTERNAL ISSUES WITH YOUR COMPANY'S GERRIT SETUP, ETC.*****
*****                                                       *****
*****   THOSE ISSUES BELONG IN DIFFERENT ISSUE TRACKERS     *****
*****                                                       *****
*****************************************************************
Status: Invalid
Sign in to add a comment

Powered by Google Project Hosting