Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

getAuthorizeHandle

getCodeURL

  • 返回获取code的url

    example
    import * as oauth from 'oauth'
    let codeConfPara: oauth.AuthCodeParameters = {
         client_id: "xxxxx48484283fc25ba0a207ea7",
         scopes: ["read", "wride"],
         state: "ss",
         auth_url: "xxx.com/baas/auth/v1.0/oauth2/authorize",
         redirect_url: "xxx.com"
         }
    let authCodeUrl = oauth.getCodeURL(codeConfPara)
    

    Parameters

    Returns String

getToken

  • 获取token

    let code = ctx.getHttp().request.queries["code"]
    let tokenConfPara:oauth.AuthTokenParameters ={
     client_id: "xxxx8484283fc25ba0a207ea7",
     client_secret: "xxxxxxxxxxxxx", // 此为敏感信息,请不要在源代码中直接写明文。
     redirect_url:"xxx.com",
     scopes:["read", "write"],
     state:"ss",
     token_url:"xxx.com/baas/auth/v1.0/oauth2/token",
     auth_style: oauth.AuthStye.AuthStyleInParams,
     code: code,
     opts: {
             "appid":"xxxxa6fde11f686edbe0"
         }
      }
    let token=oauth.getToken(tokenConfPara)
    

    Parameters

    Returns Token