當前位置: 首頁>>代碼示例>>Golang>>正文


Golang AuthorizeRequest.Client方法代碼示例

本文整理匯總了Golang中github.com/RangelReale/osin.AuthorizeRequest.Client方法的典型用法代碼示例。如果您正苦於以下問題:Golang AuthorizeRequest.Client方法的具體用法?Golang AuthorizeRequest.Client怎麽用?Golang AuthorizeRequest.Client使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/RangelReale/osin.AuthorizeRequest的用法示例。


在下文中一共展示了AuthorizeRequest.Client方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: applyAuthorization

//try login the user to the platform and apply requested permissons
func (o *Api) applyAuthorization(user, password string, ar *osin.AuthorizeRequest) error {
	log.Println(OAUTH2_API_PREFIX, "applyAuthorization")

	if usr, _, err := o.userApi.Login(user, password); err != nil {
		log.Printf(OAUTH2_API_PREFIX+"applyAuthorization: err during account login: %s", err.Error())
		return err
	} else if usr != nil {
		log.Printf(OAUTH2_API_PREFIX+"applyAuthorization: tidepool login success for userid[%s] now applying permissons", usr.UserID)
		if o.applyPermissons(usr.UserID, ar.Client.GetId(), getAllScopes()) {

			//make sure we persist any existing client userdata
			ud := ar.Client.GetUserData().(map[string]interface{})
			ud["AppUser"] = usr.UserID

			ar.Client = &osin.DefaultClient{
				Id:          ar.Client.GetId(),
				Secret:      ar.Client.GetSecret(),
				RedirectUri: ar.Client.GetRedirectUri(),
				UserData:    ud,
			}

			log.Print(OAUTH2_API_PREFIX, "applyAuthorization: user data set", ar.UserData)
			return nil
		} else {
			log.Printf(OAUTH2_API_PREFIX+"applyAuthorization: error[%s]", error_applying_permissons)
			return errors.New(error_applying_permissons)
		}
	}
	log.Printf(OAUTH2_API_PREFIX+"applyAuthorization: no user or error from login returning[%s] ", error_check_tidepool_creds)
	return errors.New(error_check_tidepool_creds)
}
開發者ID:anderspitman,項目名稱:shoreline,代碼行數:32,代碼來源:api.go


注:本文中的github.com/RangelReale/osin.AuthorizeRequest.Client方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。