OfficeDev / Office-365-SDK-for-Android

Microsoft Services SDKs for Android produced by MS Open Tech.
https://dev.office.com/android
Other
224 stars 75 forks source link

Can not sign in when running the example 'outlook' #76

Closed LiYaHX closed 9 years ago

LiYaHX commented 9 years ago

I run the sample 'outlook' and sign in with my company account, but it's always remind me 'Sorry, but we’re having trouble signing you in.We received a bad request.', why please?

(1) Here is my 'ServiceConstants.java' code :


/**
 * this class holds the service constants to connect to Office 365 Outlook services
 * please note that the sample assume that all of this constants will work for all services, which
 * may not be the case
 *
 * fill in the values according to your subscription
 */
public class ServiceConstants {
    public static final String AUTHORITY_URL = "https://login.windows.net/common";
    public static final String RESOURCE_ID = "https://outlook.office365.com/";
    public static final String REDIRECT_URL = "https://www.baidu.com/";  // Update by LY@2015-04-23
    public static final String CLIENT_ID = "GT-N8000";   // Update by LY@2015-04-23
    // public static final String ENCRYPTION_KEY = "EncryptionKey";
    // it is generally the case for O365 services that the endpoint ID is the concatenation
    // RESOURCE_ID and the api version. Please check against your actual deployment
    public static final String ENDPOINT_ID = RESOURCE_ID + "api/v1.0";
} 

(2) Here is my log: 04-23 14:55:47.824 19996-19996/com.microsoft.services.samples.outlook V/AuthenticationActivity﹕ Page finished:https://login.microsoftonline.com/common/login ver:1.0.5 04-23 14:55:47.824 19996-19996/com.microsoft.services.samples.outlook D/AuthenticationActivity﹕ displaySpinner:false showing:true ver:1.0.5 04-23 14:55:47.964 19996-19996/com.microsoft.services.samples.outlook D/WebView﹕ onSizeChanged - w:1280 h:696 04-23 14:57:29.049 19996-19996/com.microsoft.services.samples.outlook V/WebViewInputDispatcher﹕ blockWebkitDraw 04-23 14:57:29.049 19996-19996/com.microsoft.services.samples.outlook V/WebViewInputDispatcher﹕ blockWebkitDraw lockedfalse 04-23 14:57:29.049 19996-19996/com.microsoft.services.samples.outlook V/webview﹕ singleCursorHandlerTouchEvent -getEditableSupport FASLE 04-23 14:57:29.354 19996-20047/com.microsoft.services.samples.outlook D/webview﹕ blockWebkitViewMessage= false 04-23 15:27:29.019 19996-19996/com.microsoft.services.samples.outlook D/AuthenticationActivity﹕ AuthenticationActivity onPause unregister receiver ver:1.0.5 04-23 15:27:29.019 19996-19996/com.microsoft.services.samples.outlook D/AuthenticationActivity﹕ Spinner at onPause will dismiss ver:1.0.5 04-23 15:32:40.634 19996-19996/com.microsoft.services.samples.outlook D/AuthenticationActivity﹕ AuthenticationActivity onRestart ver:1.0.5 04-23 15:32:40.659 19996-19996/com.microsoft.services.samples.outlook D/AuthenticationActivity﹕ onResume ver:1.0.5 04-23 15:32:40.659 19996-19996/com.microsoft.services.samples.outlook V/AuthenticationActivity﹕ Webview onResume will register receiver:https://login.windows.net/common/oauth2/authorize?response_type=code&client_id=GT-N8000&resource=https%3A%2F%2Foutlook.office365.com%2F&redirect_uri=https%3A%2F%2Fwww.baidu.com%2F&state=YT1odHRwczovL2xvZ2luLndpbmRvd3MubmV0L2NvbW1vbiZyPWh0dHBzOi8vb3V0bG9vay5vZmZp Y2UzNjUuY29tLw &x-client-SKU=Android&x-client-Ver=1.0.5&x-client-OS=16&x-client-DM=GT-N8000&client-request-id=31b8acf5-2299-4d3f-ade5-ae3abdf5ba9d ver:1.0.5 04-23 15:32:40.659 19996-19996/com.microsoft.services.samples.outlook V/AuthenticationActivity﹕ Webview onResume register broadcast receiver for requestId1107885216 ver:1.0.5 04-23 15:35:26.194 19996-19996/com.microsoft.services.samples.outlook D/dalvikvm﹕ GC_FOR_ALLOC freed 156K, 12% free 7777K/8775K, paused 19ms, total 19ms 04-23 15:35:26.279 19996-19996/com.microsoft.services.samples.outlook V/WebViewInputDispatcher﹕ blockWebkitDraw 04-23 15:35:26.279 19996-19996/com.microsoft.services.samples.outlook V/WebViewInputDispatcher﹕ blockWebkitDraw lockedfalse 04-23 15:35:26.279 19996-19996/com.microsoft.services.samples.outlook V/webview﹕ singleCursorHandlerTouchEvent -getEditableSupport FASLE

LiYaHX commented 9 years ago

I fount more information at https://msdn.microsoft.com/office/office365/APi/files-rest-operations, i'm in China, so i need to modify the value of the parameter AUTHORITY_URL and RESOURCE_ID, meanwhile i sign up with a new account, but the error still exists after that.

Here is my modified code:

/**
 * this class holds the service constants to connect to Office 365 Outlook services
 * please note that the sample assume that all of this constants will work for all services, which
 * may not be the case
 *
 * fill in the values according to your subscription
 */
public class ServiceConstants {
    public static final String AUTHORITY_URL = "https://login.chinacloudapi.cn/common";  // The original url: https://login.windows.net/common
    public static final String RESOURCE_ID = "https://partner.outlook.cn";    // The original url: https://outlook.office365.com/
    public static final String REDIRECT_URL = "https://www.baidu.com/";  // Update by LY@2015-04-23
    public static final String CLIENT_ID = "GT-N8000";  // Update by LY@2015-04-23
    // public static final String ENCRYPTION_KEY = "EncryptionKey";
    // it is generally the case for O365 services that the endpoint ID is the concatenation
    // RESOURCE_ID and the api version. Please check against your actual deployment
    public static final String ENDPOINT_ID = RESOURCE_ID + "api/v1.0";
}
marcote commented 9 years ago

The Client ID is a GUID and you get it inside your azure account when you create an app. See this please : https://msdn.microsoft.com/en-us/dn877542.aspx

LiYaHX commented 9 years ago

OK. Thank you very much, i'll try it.

LiYaHX commented 9 years ago

Hello marcote , does Microsoft azure not support Chinese sign up?

I sign up at Microsoft azure for free trial, but i can't find my country China and can't carry on mobile verification , as a result i can't get the CLIENT_ID and REDIRECT_URL.

Could you help me again please? How should i do next?

Thanks for your help again.

marcote commented 9 years ago

Hi @LiYaHX . Honestly I have no idea, Azure subscription is beyond my knowledge. I suggest you to contact Azure support. A lot of guys from China uses the SDK so must be a way.

LiYaHX commented 9 years ago

OK. Thank you very much again, :)