Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

ERROR Error Domain=com.microsoft.graph.errors Code=500 "internal server error" #16

Closed
dimalama opened this issue Sep 28, 2017 · 8 comments

Comments

@dimalama
Copy link

Hello, I'm getting the next error when I'm running the application:
ERROR Error Domain=com.microsoft.graph.errors Code=500 "internal server error" UserInfo={error= UnknownError : {"Status":500,"Message":"All the offeractions povided in the property bag cannot be validated for the token.\u000d\u000a"}, NSLocalizedDescription=internal server error}

The initial authentication is successful but this error is happening when the code is trying to retrieve users profile information.

Screenshot of the error stack trace

I'm using Xcode 9, swift 4, iOS11 on iPhone8 simulator.

@sreejithsree123
Copy link

same for me did you find any solution it will be helpful.

@dimalama
Copy link
Author

dimalama commented Oct 4, 2017

Yeah, I made it work just reorganizing some code around, it seems like there was an issue with authenticationProvider when and how it's called. Here is my code which is work for my project.
That is my MSGraphDataService

import Foundation

class MSGraphDataService {
    
    private static let _instance: MSGraphDataService = MSGraphDataService()
    
    static var instance: MSGraphDataService {
        return _instance
    }
    
    lazy var graphClient: MSGraphClient = {
        let client = MSGraphClient.defaultClient()
        return client!
    }()

    func getUserInfo(with completion: @escaping CompletionWithErrorMessageAndData) {
        MSGraphClient.setAuthenticationProvider(AuthenticationService.instance.authenticationProvider)
        graphClient.me().request().getWithCompletion {
            (user: MSGraphUser?, error: Error?) in
            if let graphError = error {
                print("ERROR:", graphError)
                completion("MSGraphSDK Error", nil)
                
            } else {
                guard let userInfo = user else {
                    print("ERROR: Unable to get user information.")
                    completion("ERROR: Unable to get user information", nil)
                    return
                }
                
                DispatchQueue.main.async(execute: {
                    print("SUCCESS: Retrieved current user information \(userInfo)")
                })
                
                completion(nil, userInfo)
            }
        }
    }
}

and that is a part of my LoginVC where I call that service and GraphAPI

class LoginVC: UIViewController {

    @IBOutlet weak var activityIndicator: UIActivityIndicatorView!
    @IBOutlet weak var loginBtn: CustomButton!

    let graphClient = MSGraphClient()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        loadingUI(show: false)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
    func authenticate() {
        loadingUI(show: true)
        
        let clientId = ApplicationConstants.clientId
        let scopes = ApplicationConstants.scopes
        
        AuthenticationService.instance.connectToGraph(withClientId: clientId, scopes: scopes) {
            (error) in
            
            if let graphError = error {
                
                switch graphError {
                    
                case .nsErrorType(let nsError):
                    print("ERROR", nsError.localizedDescription)
                    ErrorHandlerService.instance.showError(message: "CHECK_LOG_ERROR", viewController: self, onCompletion: nil)
                    self.loadingUI(show: false)
                }
                
            } else {
                
                MSGraphDataService.instance.getUserInfo(with: { (errorMessage, data) in
                    
                    if let errorMessage = errorMessage {
                        ErrorHandlerService.instance.showError(message: errorMessage, viewController: self, onCompletion: {() in
                            AuthenticationService.instance.disconnect()
                            self.loadingUI(show: false)
                        })
                    } else if let graphUser = data as? MSGraphUser {
          

Hopefully it will help. This set up works for me.

@sreejithsree123
Copy link

sreejithsree123 commented Oct 5, 2017

thanks for your code. :)
i have a problem while adding the pod file. Bridge header issue you have any problem with that. ?. i am stuck with that issue for long time 😞 https://github.com/microsoftgraph/ios-swift-connect-sample/issues/17

@dimalama
Copy link
Author

dimalama commented Oct 5, 2017

I think you will need just to specify path in your project config build settings to point where your bridging header located in your project example

@sreejithsree123
Copy link

@dlukianenko thanks. now its working. Did you do progress bar for uploading and download. ?.

@dimalama
Copy link
Author

No I did not do progress bar

@JohnMAustin78
Copy link
Contributor

Hi there. You normally get this error when you have added the delegated profile permission to your app registration in the Azure app registration portal. You will only see the error if you are signing in with an MSA account. MSA accounts do not support the profile permission.

@jasonjoh
Copy link
Member

jasonjoh commented Mar 6, 2020

Closing this issue as we are archiving this repository. Please see https://github.com/microsoftgraph/msgraph-training-ios-swift for a Swift sample.

@jasonjoh jasonjoh closed this as completed Mar 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants