本文整理匯總了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)
}