LoginSignup
0
0

More than 3 years have passed since last update.

Android端末におけるHUAWEI IDログイン機能の詳細実装手順10-GMS端末で権限取り消し

Last updated at Posted at 2021-04-01

REST APIによる権限取り消し機能の実装方法

次のAPIでログイン時に返ってきたアクセストークン(IDトークンではない)をパラメータとして渡し、権限を取り消します。

API:https://oauth-login.cloud.huawei.com/oauth2/v3/revoke
メソッド:POST
パラメータ:

パラメータ名
token https://oauth-login.cloud.huawei.com/oauth2/v3/token のレスポンスのaccess_token
HmsHuaweiIdLogic.kt
override fun cancelAuthorization(context: Context, accessToken: String) {
    val queue = Volley.newRequestQueue(context)

    val postRequest: StringRequest = object : StringRequest(
        Method.POST,
        "https://oauth-login.cloud.huawei.com/oauth2/v3/revoke",
        object : Response.Listener<String> {
            override fun onResponse(response: String?) {
                // 権限取り消し成功
            }
        },
        object : Response.ErrorListener {
            override fun onErrorResponse(error: VolleyError?) {
                error?.printStackTrace()
            }
        }
    ) {
        override fun getBodyContentType(): String {
            return "application/x-www-form-urlencoded"
        }

        override fun getParams(): Map<String, String> {
            val params: MutableMap<String, String> = HashMap()
            params["token"] = accessToken
            return params
        }
    }

    queue.add(postRequest)
}

シリーズ

GitHub

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0