In this paper, we propose a novel gait authentication mechanism by mining sensor resources on mobile phone. Unlike previous works, both built-in accelerometer and magnetometer are used to handle mobile installation issues, including but not limited to disorientation, and misplacement errors. The authentication performance is improved by executing deep examination at pre-processing steps. A novel and effective segmentation algorithm is also provided to segment signal into separate gait cycles with perfect accuracy. Subsequently, features are then extracted on both time and frequency domains. We aim to construct a lightweight but high reliable model; hence feature subsets selection algorithms are applied to optimize the dimension of the feature vectors as well as the processing time of classification tasks. Afterward, the optimal feature vector is classified using SVM with RBF kernel. Since there is no public dataset in this field to evaluate fairly the effectiveness of our mechanism, a realistic dataset containing the influence of mobile installation errors and footgear is also constructed with the participation of 38 volunteers (28 males, 10 females). We achieved the accuracy approximately 94.93% under identification mode, the FMR, FNMR of 0%, 3.89% and processing time of less than 4 seconds under authentication mode.