Can I get device id (android device id for example) at login in a rule ? How?

The device id isn’t transferred automatically, but you can pass it along in the authorization request.
I guess you’re using a regular OAuth2 redirect flow, or the standard way we recommend via AndroidSDK?

If you look for extraParams in this forum, you find a way, though this extraParams isn’t part of the OAuth2 specs.

While it (still) works, I would rather recommend this:

Pass an upstream_params parameter in the authorization request. I don’t know the details of the Android SDK so I show you the way in our JS SDK, but it’s the same approach in Android then accordingly.

this.$auth.loginWithRedirect({"upstream_params":"myDeviceId"});

In the Rule, you can then get it via:

context.request.query.upstream_params